How would you compare floats & doubles sent into QML functions from Cpp side ?
If I want to do a high precision comparasion like below as mentioned here
bool AreSame(double a, double b) {
return fabs(a - b) < EPSILON;
}
How should I do this in Qt QML ?
Or, Is it that it gets casted to real in QML & one need not worry about it?
You should do it the same as in JavaScript:
x = 0.2 + 0.1;
y = 0.3;
equal = Math.abs(x - y) < Number.EPSILON;
Please note that this value property is available since Qt 5.8. In previous Qt releases you can define your own epsilon, e.g. as:
readonly property double epsilon: Math.pow(2, -52)