# Buffer parser and influxdb with 64bit number

**URL:** <https://discourse.nodered.org/t/buffer-parser-and-influxdb-with-64bit-number/90556>\
**Category:** General\
**Tags:** database, function-node\
**Created:** [30 August 2024 13:32 UTC](https://discourse.nodered.org/t/buffer-parser-and-influxdb-with-64bit-number/90556 "2024-08-30T13:32:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PAT](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@PAT](https://discourse.nodered.org/u/PAT)\
**Post date:** [30 August 2024 13:32 UTC](https://discourse.nodered.org/t/buffer-parser-and-influxdb-with-64bit-number/90556/1 "2024-08-30T13:32:44Z")

</div>

hi all

hope someone could shed some light on this issue.

I am reading 2 x 64 unsighned numbers from an energy meter. and trying to pass it to influx.  
in the same flow i am passing 64 bit double floating point numbers to db perfectly. however a standard 64 bit number will not go through. no errors in debug just never shows up in the db. The only thing i see that is strange is that the debug node shows the correct number followed by an "n"

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

yet in the debug column it is not there.?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/4/64e332f4ec21d0fe7581310fc5d28b6991c855b9.png)

here is a pic of my buffer parser settings.

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

it is not my influx node that is the problem , because if i route the flow to the influx node above which is working perfectly. i have the same result. biggest thing i have never seen an n attached to the end of an interger before. Any ideas

---

<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:** [30 August 2024 14:07 UTC](https://discourse.nodered.org/t/buffer-parser-and-influxdb-with-64bit-number/90556/2 "2024-08-30T14:07:07Z")

</div>

> [@PAT](#):
>
> he only thing i see that is strange is that the debug node shows the correct number followed by an "n"

Numbers in JavaScript have a max size of (2^53 – 1) **Docs**

Proof

```auto
console.log(Number.MAX_SAFE_INTEGER); // Outputs: 9007199254740991
console.log(Number.MIN_SAFE_INTEGER); // Outputs: -9007199254740991

```

To avoid precision losses, buffer-parser uses [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) for 64 bit numbers.

These are displayed with an `n` at the end to clearly denote they are indeed `BigInt` values not regular `Numbers`. That is NOT the buffer parser, that is JS!

Proof (NodeJs Repl)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/50e5fa146637a63836211fae183337932210c64b.png)

  

> [@PAT](#):
>
> it is not my influx node that is the problem

I am afraid it most likely is! The issue is that influx node probably does not know how to deal with `BigInt` typed numbers. As you can see from your own screenshot, the 64bit BigInt IS present and correct coming out of the buffer parser!

To change the `BigInt`s into regular numbers (and risk loss) you can use the `Number` function

e.g.

**Function Node**

```auto
msg.payload['TOTAL kWH'] = Number(msg.payload['TOTAL kWH'])
return msg

```

---

<div class="post-metadata">

**Author:** ![PAT](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@PAT](https://discourse.nodered.org/u/PAT)\
**Post date:** [31 August 2024 12:05 UTC](https://discourse.nodered.org/t/buffer-parser-and-influxdb-with-64bit-number/90556/3 "2024-08-31T12:05:36Z")

</div>

Thanks Steve

It worked perfectly. and with no precision loss although my number is still quite small. i even landed up shaving the last 3 digits to make the number more readable.

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

working as expected

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

you are 100 percent correct on the max number size for influx . i found their docs while i was lying in bed after posting the plea for help. When i stated infulx was not the problem it was because i was passing 64bit 754 ieee double precision floating point and that was working fine. lesson learnt i assume it is passed to db as 2 x 32 bit values.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/9/7923d3e053bacaacbf79382f8623ea73d67c1c0d.png)

thank you for saving my day  
Pat

---

<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:** [14 September 2024 12:05 UTC](https://discourse.nodered.org/t/buffer-parser-and-influxdb-with-64bit-number/90556/4 "2024-09-14T12:05:55Z")

</div>

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