float s = float.Parse("10499.9705314636");
Now s
has the value 10499.97
.
Is there a way to save all the precision digits?
float s = float.Parse("10499.9705314636");
Now s
has the value 10499.97
.
Is there a way to save all the precision digits?
You may want to look into the difference between float, double, and decimal. Pay special attention to the difference between a binary floating point type, and a decimal floating point type. Decimal data type is likely what you're looking for here, as float doesn't have enough significant digits to store the number you're trying to parse accurately.
Try using a data type with a higher precision than
float
, such asdouble
. The remaining digits of your value are truncated due to the size of the data typefloat
:Prints:
You should try and use
decimal
instead.