# Need math or change

**URL:** <https://discourse.nodered.org/t/need-math-or-change/18096>\
**Category:** General\
**Created:** [18 November 2019 12:28 UTC](https://discourse.nodered.org/t/need-math-or-change/18096 "2019-11-18T12:28:32Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibottobi](https://avatars.discourse-cdn.com/v4/letter/i/e95f7d/32.png) [@ibottobi](https://discourse.nodered.org/u/ibottobi)\
**Post date:** [18 November 2019 12:28 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/1 "2019-11-18T12:28:32Z")

</div>

Hello,

I have a msg.payload with something like 130.33 e-42 and I want to have the decimal result 312.27, or rounded 312 back.  
Do I have to use math for this?  
Thanks in advance.  
Tobias

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [18 November 2019 12:35 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/2 "2019-11-18T12:35:11Z")

</div>

Yes! Perhaps you should explain a little more.

---

<div class="post-metadata">

**Author:** ![ibottobi](https://avatars.discourse-cdn.com/v4/letter/i/e95f7d/32.png) [@ibottobi](https://discourse.nodered.org/u/ibottobi)\
**Post date:** [18 November 2019 13:00 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/3 "2019-11-18T13:00:20Z")

</div>

I'm reading TCP-Modbus data out of a power-unit.  
My payload is a number (picture) an I want to convert the payload to decimal value.

 ![20191118_125808628_iOS](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/30267b489bf873f66f1964b67a47f856ae29b217.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 November 2019 13:24 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/4 "2019-11-18T13:24:45Z")

</div>

In your example you say you want 130.33 e-42 to display as 312.27, but I don't see in what way those numbers are related.  
What does the Payload 1 function do?

---

<div class="post-metadata">

**Author:** ![ibottobi](https://avatars.discourse-cdn.com/v4/letter/i/e95f7d/32.png) [@ibottobi](https://discourse.nodered.org/u/ibottobi)\
**Post date:** [18 November 2019 13:39 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/5 "2019-11-18T13:39:20Z")

</div>

Function "Payload 1" is just extracting the msg.payload[1]

The upper debug is the origin payload from the modbus, the socond after the "Payload1"

 ![20191118_133405168_iOS](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d7805ac9fe5fc94c07050e492e30fc516548d31f.png)

---

<div class="post-metadata">

**Author:** ![jtmoderate876](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jtmoderate876/32/6423_2.png) [@jtmoderate876](https://discourse.nodered.org/u/jtmoderate876)\
**Post date:** [18 November 2019 15:44 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/6 "2019-11-18T15:44:21Z")

</div>

Note that 1.2317e-319 is actually a super small number of 0.0000[with 300+zeros]0012317

You would need to multiply by something to get a rounded integer but e-319 is so small that you can't just multiply it by 1e+319 (I get infinite or overflow)

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [18 November 2019 15:47 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/7 "2019-11-18T15:47:20Z")

</div>

> [@ibottobi](#):
>
> My payload is a number (picture) an I want to convert the payload to decimal value.

The payload is a decimal value, a very small one, that is a 0.000000000 with318 zeroes 1257. Are you sure you are reading data correctly and that your calculation in the function node is correct?  
[edit] @jtmoderate876 beat me to it!

---

<div class="post-metadata">

**Author:** ![ibottobi](https://avatars.discourse-cdn.com/v4/letter/i/e95f7d/32.png) [@ibottobi](https://discourse.nodered.org/u/ibottobi)\
**Post date:** [18 November 2019 15:57 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/8 "2019-11-18T15:57:21Z")

</div>

> [@jtmoderate876](#):
>
> 1.2317e-319

1.2317e-319 is in math (1.2317\*e) -319 = -315.651892272

---

<div class="post-metadata">

**Author:** ![jtmoderate876](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jtmoderate876/32/6423_2.png) [@jtmoderate876](https://discourse.nodered.org/u/jtmoderate876)\
**Post date:** [18 November 2019 16:06 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/10 "2019-11-18T16:06:18Z")

</div>

> [@ibottobi](#):
>
> 1.2317e-319 is in math (1.2317\*e) -319 = -315.651892272

I believe you have it wrong and that is not correct.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [18 November 2019 16:08 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/11 "2019-11-18T16:08:22Z")

</div>

> [@ibottobi](#):
>
> 1.2317e-319 is in math (1.2317\*e) -319 = -315.651892272

But in JavaScript, `1.2317e-391` is `1.2317 * 10^-391`

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [18 November 2019 16:08 UTC](https://discourse.nodered.org/t/need-math-or-change/18096/12 "2019-11-18T16:08:50Z")

</div>

The debug window shows the direct numerical representation, in scientific mode for the exponent. What you’re referencing is Euler’s number, the mathematical constant `e`. The number displayed in the debug window is however not a mathematical representation of a formula, but just a number.
