it should still fix some issue IEEE754 singleprecision float has only 24 bits of mantissa, so obviously it can't represent exactly all integers in the 32bit range For example if x = 16777216.0f, y = 1.0f then x + y is not equal to 16777217
Boards Message : 
You Must Login
Or Sign Up
to Add Your Comments . 
Share :

Representing integers in doubles
Date : March 29 2020, 07:55 AM
will be helpful for those in need An IEEE754 64bit double can represent any 32bit integer, simply because it has 53odd(a) bits available for precision and the 32bit integer only needs, well, 32 :) It would be plausible for a (non IEEE754 double precision) 64bit floating point number to have less than 32 bits of precision. That would allow truly huge numbers (due to the exponent) but at the cost of precision.

Why does this precision fail example show up with doubles but not with floats?
Tag : java , By : dantino
Date : March 29 2020, 07:55 AM
around this issue There are eight interesting values involved here (four for each type). Their exact values are: Double values 1.03d: 1.0300000000000000266453525910037569701671600341796875
0.42d: 0.419999999999999984456877655247808434069156646728515625
Result: 0.6100000000000000976996261670137755572795867919921875
0.61d: 0.60999999999999998667732370449812151491641998291015625
1.03f: 1.0299999713897705078125
0.42f: 0.4199999868869781494140625
Result: 0.61000001430511474609375
0.61f: 0.61000001430511474609375

Do floats, doubles, and long doubles have a guaranteed minimum precision?
Date : March 29 2020, 07:55 AM
this one helps. If std::numeric_limits::is_iec559 is true, then the guarantees of the IEEE 754 standard apply to floating point type F. Otherwise (and anyway), minimum permitted values of symbols such as DBL_DIG are specified by the C standard, which, undisputably for the library, “is incorporated into [the C++] International Standard by reference”, as quoted from C++11 §17.5.1.5/1.

How would you high precision compare floats & doubles sent into QML functions from Cpp side?
Tag : qt , By : Luciano Campos
Date : March 29 2020, 07:55 AM
around this issue You should do it the same as in JavaScript: x = 0.2 + 0.1;
y = 0.3;
equal = Math.abs(x  y) < Number.EPSILON;
readonly property double epsilon: Math.pow(2, 52)

Why should I use Integers when I could just use floats or doubles in C#?
Tag : chash , By : paolodm
Date : March 29 2020, 07:55 AM

