Floating point values ββand loss accuracy
Remember that a floating point number can only approximate a decimal number, and that the precision of a floating point number determines how exactly this number approaches a decimal number. By default, the Double Value contains 15 decimal digits of precision, although a maximum of 17 digits are stored internally. floating point precision has several consequences:
Two floating-point numbers appear equal to a specific precision; do not compare equal ones, because their smallest significant digits are different.
A mathematical or comparative operation that uses a floating point number may not give the same result if a decimal number is used, since a floating point number may not match exactly to approximate the decimal number.
The value cannot round if a floating point number. The value is considered rounded if the operation converts the original floating point number to another form, the reverse operation converts the converted form back to a floating point number, and the final floating point number is equal to the original floating point number. roundtrip may fail because one or the least significant digits are lost or changed in the conversion.
In addition, the result of arithmetic and assignment operations using Double values ββmay vary slightly by platform due to the loss of accuracy of the Double type. For example, the result of assigning a literal double value may differ in the 32-bit and 64-bit versions of the .NET Framework. The following example illustrates this difference when the literal value -4.42330604244772E-305 and a variable whose value is -4.42330604244772E-305 are assigned to a double variable. Note that the result of the Parse (String) method in this case does not suffer from a loss of precision.