Yo uwant to have even more floating point fun?
How many starts does this method print?
1 2 3 4 5 6 7
| public method printStars(float start){ float end = start + 100;
while (start++<end) { System.out.print("*"); } } |
The answer is its indeterminate and based on the value of start.
Because floats are an aproximation whose accuracy changes with
the value, if start is high enough start++ becomes a nop lost iin
the rounding and its an idiot loop!
For this reason i personally believe that allowing ++ on floats was a syntactic error on the part of the original Java designers.