I am getting unusual multiplication result in dart.
var val = 588.82;
print(val * 100); //result 58882.00000000001
What is the reason for this and how can I get the correct answer?
I am getting unusual multiplication result in dart.
var val = 588.82;
print(val * 100); //result 58882.00000000001
What is the reason for this and how can I get the correct answer?
This "problem" come with the IEEE 754 Standard, the floating point.
In short, many fractional double values are not precise.
588.82 is not really 588.82, if you want the correct value, you should probably round the result of the multiplication with two decimal.
void main() {
var val = 588.82;
print((val * 100).toInt());
}