K
K
KzLIFE2016-10-27 19:44:21
Node.js
KzLIFE, 2016-10-27 19:44:21

How to convert negative int32 to int64 in nodejs?

There is a server on Nodejs, through it I connect to the Mysql database, in the database there is one table Items (id, id2);
id is an int;
id2 is bigint;
when receiving a record, it displays -1556717912 for me, and in the base 2738249384.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri, 2016-10-28
@KzLIFE

since the node does not support 64 bits of the number, then when stored in int32, part of the number is lost. converting is useless.
in your case as a temporary solution.
2^32 - 1556717912 = 2738249384
(2^32 = 4294967296)
but as soon as the id exceeds 2^32, it won't help.
if you need more, then you need to rewrite the module that you use to communicate with mysql. so that it returns them as a floating point number, where the least significant bits, as far as I know, disappear starting from 2 ^ 53, this should be enough.

A
Alexander Aksentiev, 2016-10-27
@Sanasol

nodejs int64

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question