Hi,
I'm trying to call a slot which accepts a qint64 as an argument-
class Foo : public QObject
{
Q_OBJECT
public slots:
void open(qint64 id) {
qDebug() << "Opening" << id;
}
};
from QML-
onClicked: {
console.log("Opening " + userId);
foo.open(userId);
}
and I see t
JS numbers are stored as double AFAIK hence for big numbers the lowest bits
will be less precise.
---
Jean-Michaël Celerier
http://www.jcelerier.name
On Wed, Jul 12, 2017 at 11:53 AM, Shantanu Tushar
wrote:
> Hi,
>
> I'm trying to call a slot which accepts a qint64 as an argument-
>
> cla
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
Hi
On Wed, Jul 12, 2017 at 3:30 PM, Konrad Rosenbaum 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 J
2017-07-12 12:00 GMT+02:00 Konrad Rosenbaum :
> 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 number
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
On quarta-feira, 12 de julho de 2017 03:31:54 PDT Ilya Diallo wrote:
> That's 64bits actually. For integers you're safe up to (2^53 -1), so the
> OP's value should be ok as it's below that value.
Nitpick: it's actually 2^53,. The first non-representable number is
2^53 + 1.
--
Thiago Macieira - t
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 an
Thanks for the reply everyone, so the takeaway is so always store 64-bit
ints as strings in JavaScript, I'll start making that change in our
codebase.
However, I'm still curious on how `console.log` got the output right and it
the precision loss only happened when it went from QML/JS to C++ . Any
2017-07-13 8:03 GMT+02:00 Shantanu Tushar :
> Thanks for the reply everyone, so the takeaway is so always store 64-bit
> ints as strings in JavaScript, I'll start making that change in our
> codebase.
>
> However, I'm still curious on how `console.log` got the output right and
> it the precision l
10 matches
Mail list logo