# Decimal to Binary signed 2's complement

**URL:** https://discourse.nodered.org/t/decimal-to-binary-signed-2s-complement/45834
**Category:** General
**Created:** [18 May 2021 12:09 UTC](https://discourse.nodered.org/t/decimal-to-binary-signed-2s-complement/45834 "2021-05-18T12:09:36Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [18 May 2021 12:36 UTC](https://discourse.nodered.org/t/decimal-to-binary-signed-2s-complement/45834/8 "2021-05-18T12:36:19Z")

</div>

Firstly, in order to make code more readable and importable it is important to surround your code with three backticks  
`````  
`like this`  
`````

You can edit and correct your post by clicking the pencil icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

  
  

> [@Aivaras](#):
>
> Maybe you can repair this code ?

> [@Aivaras](#):
>
> Input is a string '3328'

```auto
var input = Number(msg.payload);
msg.payload = input.toString(2).padStart(16,"0") ;
return msg;

```

---

_[View the full topic](https://discourse.nodered.org/t/decimal-to-binary-signed-2s-complement/45834)._
