[Interest] JS numbers to qint64

Andrew Ialacci andrew at dkai.dk
Wed Jul 12 17:09:37 CEST 2017


Any fancy math, do in C++ with a floating-point library and pass to JS/QML as a string purely for the intent of displaying in the UI. The only exception should be for layout / item positioning. There are single JS file floating point libs but… Use C++ :P

Disclaimer: This is just a suggestion and could likely be wrong. Definitely defer to anything anyone else suggests on this mailing list as they are all smarter than me!





On 7/12/17, 10:55 AM, "Interest on behalf of Thiago Macieira" <interest-bounces+andrew=dkai.dk at qt-project.org on behalf of thiago.macieira at intel.com> wrote:

    On quarta-feira, 12 de julho de 2017 02:53:39 PDT Shantanu Tushar wrote:
    > qml: Opening 5762702576189441
    > Opening 5762702576189442
    > 
    > As you can see the number changes. What am I doing wrong?
    
    Expecting JS numbers to be precise.
    
    Remember that in JavaScript, numbers are actually double-precision floating 
    point. They are lossy.
    
    They can represent with fidelity only in the range ±2^53. Yours is inside the 
    range (only just!) but a simple manipulation of it could throw it outside for 
    a while.
    
    I recommend staying well away from the limits. Like limiting to 32 bits.
    
    -- 
    Thiago Macieira - thiago.macieira (AT) intel.com
      Software Architect - Intel Open Source Technology Center
    
    _______________________________________________
    Interest mailing list
    Interest at qt-project.org
    http://lists.qt-project.org/mailman/listinfo/interest
    



More information about the Interest mailing list