# How to do proper number calculations in a Payload Format decoder?

**URL:** <https://www.thethingsnetwork.org/forum/t/how-to-do-proper-number-calculations-in-a-payload-format-decoder/32799>\
**Category:** Application Development\
**Created:** [December 19, 2019, 4:13pm UTC](https://www.thethingsnetwork.org/forum/t/how-to-do-proper-number-calculations-in-a-payload-format-decoder/32799 "2019-12-19T16:13:54Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [December 19, 2019, 7:34pm UTC](https://www.thethingsnetwork.org/forum/t/how-to-do-proper-number-calculations-in-a-payload-format-decoder/32799/3 "2019-12-19T19:34:23Z")

</div>

There are quite a few things going on here:

- Like @cslorabox already noted: JavaScript is not the same as Java. The payload formats in TTN Console use JavaScript (ECMAScript 5 to be precise). See also [MDN Web Docs](https://developer.mozilla.org/) to learn that.

- **JavaScript’s decimal numbers are not exact.**

- Apparently your device’s code is converting the decimal coordinates into positive integer numbers. However, when using bitwise operators in your decoder, then [JavaScript expects _signed_ 32 bits numbers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Signed_32-bit_integers) using [two’s complement encoding](https://en.wikipedia.org/wiki/Two%27s_complement), hence allowing for numbers from -2,147,483,648 through 2,147,483,647.

Finally, next time please don’t post screenshots for text: even after I cropped the image it’s hard to read on small devices, and it’s impossible to copy or quote. See [How do I format my forum post? [HowTo]](https://www.thethingsnetwork.org/forum/t/how-do-i-format-my-forum-post-howto/8735) Also, I doubt the output shown for longitude goes with the code that is shown…?

---

_[View the full topic](https://www.thethingsnetwork.org/forum/t/how-to-do-proper-number-calculations-in-a-payload-format-decoder/32799)._
