precision - comparison float rounding fails System.Math.RoundTo C++ XE7 -
i've been trying round float value 4 precision without success.
float fconv = 1.0f; float fdata = 39.934543423412f; float fres = roundto(fdata*fconv, -4); if(fres <= 39.9345f){do something;} //<-- unwanted behavior
wanted result 39.934500000000
actual result 39.934543423412
i've tried many methods including round float given precision without success.
i'm working on amd fx83xx 64bit. program built in 32bit debug using xe7
thanks
your desired precision of 6 decimal digits near precision limits float data type. epsilon, or delta between consecutive representable floating point values, number around 40f 7.63e-6, there's couple of bits different between 'best' value , you're getting. possibly due rounding close limit, i'm not sure.
Comments
Post a Comment