What is happening here is that the true value of the floating-point number written as 0.1 is slightly larger than the numerical value 1/10 while 6.0 represents the number 6 precisely. Therefore the true value of 6.0 / 0.1 is slightly less than 60. When doing division, this is rounded to precisely 60.0 , but fld(6.0, 0.1) always takes the floor of the true value, so the result is 59.0 .
And, you should be using proper float division with /, not div.
This might work, but it doesn’t really signal the intent of the code, just “Do whatever range does”. Will it work equally well for other input values? We don’t know, because the OP’s intent is unclear.
Yes, it was just a matter of me wanting cleaner looking code.
The reason I started this thread wasn’t even the issue of creating the array, I just thought the div behaviour was unintended as I didn’t see the doc comment about it.
I’m still grateful for all the suggestions.