-4

I need an alternative to this simple math.

float FreqA = 28.333334;
FreqA = FreqA+0.000001;
println(FreqA);

However this results in 28.333336. How do I perform this math to get the correct answer of 28.333335?

I have tried converting the float to an integer performing the math, than converting back to a float, but I get the same mathematical errors.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294

1 Answers1

1

Chances are very high that your programming environment has a double datatype. This type uses more memory than a float, but offers higher precision.

https://en.wikipedia.org/wiki/Double-precision_floating-point_format

Glorfindel
  • 21,988
  • 13
  • 81
  • 109