Single, double and precision

I know that storing a single value (or double) cannot be very accurate. therefore saving, for example, 125.12, can lead to 125.1200074788. now in delphi there is some useful function, such as valuevalue or comparevalue, which accept epsilon as param and say that 125.1200074788 or, for example, 125.1200087952 is equal.

but I often see things in codes like: if aSingleVar = 0, then ... and this actually, as I see it, always works. What for? why saving for example 0 in one var saves the exact value?

+6
source share
2 answers

, m*2^e, m e , ( , ). 0 , 125.12 , 3128/25, 1/25 2.

125.12 ( ) False, 125.12 , ( ) .

+9

, BigDecimals . .

-1

Source: https://habr.com/ru/post/1014282/


All Articles