# Calculations within node-red

**URL:** <https://discourse.nodered.org/t/calculations-within-node-red/16505>\
**Category:** General\
**Created:** [9 October 2019 11:33 UTC](https://discourse.nodered.org/t/calculations-within-node-red/16505 "2019-10-09T11:33:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinisz](https://avatars.discourse-cdn.com/v4/letter/v/b2d939/32.png) [@vinisz](https://discourse.nodered.org/u/vinisz)\
**Post date:** [9 October 2019 11:33 UTC](https://discourse.nodered.org/t/calculations-within-node-red/16505/1 "2019-10-09T11:33:56Z")

</div>

Hi All,

quite new here, so don't blame me posting in wrong category.  
I need node-red to do a specific calculation, how should I do that and is the function node my best option here ?

The calculation is

newpayload = 10^((payload-109)/32)

The challenge is mostly with the exponent "^" character or so it is called I believe....  
If someone can help me out how to do this calculation (input payload is a number) then that would be great !

---

<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:** [9 October 2019 11:39 UTC](https://discourse.nodered.org/t/calculations-within-node-red/16505/2 "2019-10-09T11:39:07Z")

</div>

Hi @vinisz

The Function node is probably the easiest place to start with this sort of thing.

The node uses JavaScript and there is a good guide on the built-in [Math object here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math).

And more specifically, the [Math.pow() function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow).

With that in mind, a Function node with the following code should do what you want.

```auto
msg.payload = Math.pow(10, (msg.payload-109)/32);
return msg;

```
