# Why i'm getting NAN in debug of temp value

**URL:** https://discourse.nodered.org/t/why-im-getting-nan-in-debug-of-temp-value/39477
**Category:** General
**Created:** [21 January 2021 08:31 UTC](https://discourse.nodered.org/t/why-im-getting-nan-in-debug-of-temp-value/39477 "2021-01-21T08:31:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![arvind423](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/arvind423/32/35714_2.png) [@arvind423](https://discourse.nodered.org/u/arvind423)
#### Post date: [21 January 2021 08:31 UTC](https://discourse.nodered.org/t/why-im-getting-nan-in-debug-of-temp-value/39477/1 "2021-01-21T08:31:27Z")

</div>

```auto
var temp1= msg.payload[6]-48;
var temp2= msg.payload[7]-48;
var temp3= msg.payload[9]-48;
var temp4= msg.payload[10]-48;

var result = (temp1*1000)+ (temp2*100) + (temp3*10) + temp4; 
result = result/100;

var result1 = {payload:result};

return[result1];

```

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [21 January 2021 09:33 UTC](https://discourse.nodered.org/t/why-im-getting-nan-in-debug-of-temp-value/39477/2 "2021-01-21T09:33:19Z")

</div>

presumably one of those inputs is not of numeric type...  
can you show us the incoming payload ? feed into a debug node and show us the result.

---

<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: [21 January 2021 10:10 UTC](https://discourse.nodered.org/t/why-im-getting-nan-in-debug-of-temp-value/39477/3 "2021-01-21T10:10:22Z")

</div>

Is the payload you are passing in a string, array or Buffer?  
Feed it into a debug node and it will tell you

**[Edit]** If it is a string, which I suspect it is then try this

```auto
msg.payload = Number(msg.payload.substr(6,4))
return msg;

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [22 March 2021 10:10 UTC](https://discourse.nodered.org/t/why-im-getting-nan-in-debug-of-temp-value/39477/4 "2021-03-22T10:10:33Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
