# Get wrong number from debug node

**URL:** <https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296>\
**Category:** General\
**Tags:** function-node\
**Created:** [16 December 2022 07:13 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296 "2022-12-16T07:13:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThisIsFrankTsai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thisisfranktsai/32/71476_2.png) [@ThisIsFrankTsai](https://discourse.nodered.org/u/ThisIsFrankTsai)\
**Post date:** [16 December 2022 07:13 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/1 "2022-12-16T07:13:45Z")

</div>

Hi,there

Please helped me,

I designed a simple flow as below,

timestample -\> function -\>debug

My function dseigined as below,

```auto
msg.payload =0x01033120000C4AF9;
return msg;

```

I send 0x01033120000C4AF9 (hex)

But I got the wrong number 0x01033120000C4B00 (hex) in debug node.

The code and picture as attactment

![4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/1/31acc945a99734a3f486d85572f4dead52e86568.jpeg)  
 ![3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8ab32a0c76ff33eaea852ecc1821375ed97f76f3.jpeg)

 ![2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5a2f8c4a41011cf6e46b789c052bd357912aaa86.jpeg)  
 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/77430fe8420fc7d25694a402b8d9ebcc98d3d8e9.jpeg)  
[TestFlow.json](https://discourse.nodered.org/uploads/short-url/zP8deh0l3zPvp2BPmb0AwlnBrVp.json) (1.6 KB)

---

<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:** [16 December 2022 07:29 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/2 "2022-12-16T07:29:48Z")

</div>

Is that larger than the maximum integer that can be held accurately in JavaScript? Google for  
JavaScript maximum integer  
To check.

---

<div class="post-metadata">

**Author:** ![ThisIsFrankTsai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thisisfranktsai/32/71476_2.png) [@ThisIsFrankTsai](https://discourse.nodered.org/u/ThisIsFrankTsai)\
**Post date:** [16 December 2022 07:32 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/3 "2022-12-16T07:32:19Z")

</div>

Thank you for your reply

But my teacher can show the correct number as the same flow.

---

<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:** [16 December 2022 09:23 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/4 "2022-12-16T09:23:48Z")

</div>

Indeed as @Colin suggests

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a853a3006407d1e5958e2c07b1b2c1dfe1ba542f.png)

---

<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:** [16 December 2022 09:45 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/5 "2022-12-16T09:45:32Z")

</div>

> [@ThisIsFrankTsai](#):
>
> But my teacher can show the correct number as the same flow.

Did he use `BigInt`?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/0/8075481428c71669c6f28c80124343c139a0d53b.png)

### NOTE: To clarify for future readers.

The problem is not with Node-RED or the debug panel, it is due to the design on the Number type.

See: [Number.isSafeInteger() - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ff2053c273b69b066a089310f4f7073a18b607a8.png)

---

<div class="post-metadata">

**Author:** ![ThisIsFrankTsai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thisisfranktsai/32/71476_2.png) [@ThisIsFrankTsai](https://discourse.nodered.org/u/ThisIsFrankTsai)\
**Post date:** [16 December 2022 10:15 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/6 "2022-12-16T10:15:03Z")

</div>

How should i fix this problem?

i would send the larger number

---

<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:** [16 December 2022 11:10 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/7 "2022-12-16T11:10:41Z")

</div>

> [@ThisIsFrankTsai](#):
>
> How should i fix this problem?

That depends on what do you want to do with that number.

---

<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:** [16 December 2022 12:12 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/8 "2022-12-16T12:12:34Z")

</div>

> [@ThisIsFrankTsai](#):
>
> How should i fix this problem?

As I went to extreme lengths to demonstrate...

> [@Steve-Mcl](#):
>
> use `BigInt`?
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/0/8075481428c71669c6f28c80124343c139a0d53b.png)

Use BigInt

* * *

Of course, it matters where you are sending this?

---

<div class="post-metadata">

**Author:** ![ThisIsFrankTsai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thisisfranktsai/32/71476_2.png) [@ThisIsFrankTsai](https://discourse.nodered.org/u/ThisIsFrankTsai)\
**Post date:** [19 December 2022 06:00 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/9 "2022-12-19T06:00:54Z")

</div>

I have a device that receive hex number ,when the device receive right instruction,  
it will send the state to me.  
I designed the flow as the photo.

If you have any idea ,please tell me.

 ![1671429587965](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5a283d1d7331a8711df3364ead39638c3db662db.jpeg)

---

<div class="post-metadata">

**Author:** ![ThisIsFrankTsai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thisisfranktsai/32/71476_2.png) [@ThisIsFrankTsai](https://discourse.nodered.org/u/ThisIsFrankTsai)\
**Post date:** [19 December 2022 06:09 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/10 "2022-12-19T06:09:43Z")

</div>

Thank you Steve-Mcl

I have used BigInt function in function node,but i also get wrong number.

as photo

 ![1671430011431](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/1245b3b7e31ddc59aa0db44aae4d5fff932a3165.jpeg)  
 ![1671430021420](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6fb9bd2469d2d34df1ccd708dbfdfd521f365d5f.jpeg)  
 ![1671430147927](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/ca7234b4c5c167d47c0aec549a4076b0559150ff.jpeg)

---

<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:** [19 December 2022 07:00 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/11 "2022-12-19T07:00:32Z")

</div>

You have put brackets around the number and then called toString causing the number to be evaluated before the call to bigint

Take another look at my screenshot

---

<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:** [17 February 2023 07:01 UTC](https://discourse.nodered.org/t/get-wrong-number-from-debug-node/72296/12 "2023-02-17T07:01:33Z")

</div>

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