This is about floating point arithmetic. When you reduce the number that you come across the situation when you pass the number f = 1.23456792E8 , everything goes wrong, because f-1 and f have the same floating point representation. Thus, decrementation makes the number itself, which leads to an infinite loop. Just check:
System.out.println(1.23456792E8f); System.out.println(1.23456792E8f - 1);
What is so special about quantity and why does execution stop? This is because the 123456789 floating point representation is 1.23456792E8 . This already gives us a space of at least 3 due to the lack of precision of floating point numbers. Using double instead of float makes the program complete, but the problem will occur with higher numbers.
source share