[Interest] JS numbers to qint64

Shantanu Tushar shaan7in at gmail.com
Wed Jul 12 12:11:14 CEST 2017


Hi

On Wed, Jul 12, 2017 at 3:30 PM, Konrad Rosenbaum <konrad at silmor.de> wrote:

> On Wed, July 12, 2017 11:53, Shantanu Tushar wrote:
> > and I see this output-
> >
> > qml: Opening 5762702576189441
> > Opening 5762702576189442
> >
> > As you can see the number changes. What am I doing wrong?
>
> ...you are using JavaScript numbers. All numbers is JS are 32bit floats,
> so naturally when you get to high numerical values you lose precision.
>

What is interesting is that I had declared the variable like this-

property var userId: 5762702576189441

And console.log prints the right value. Shouldn't that be wrong as well?

Unless the numerical value is somehow important to the user: try to wrap
> those numbers in something more opaque.
>

Any suggestions on what that can be? I tried QVariant instead of qint64 but
that didn't help, its still the wrong value.


>
>   Konrad
>
>
Cheers,

-- 
Shantanu Tushar    (UTC +0530)
shantanu.io
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170712/088cdc4f/attachment.html>


More information about the Interest mailing list