lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Dirk Laurie <dirk.laurie@gmail.com> wrote:

> 2017-11-16 5:15 GMT+02:00 Paige DePol <lual@serfnet.org>:
> 
>> Yes, it probably should as the loop with a step size of maxint/2 does run
>> the correct number of times... testing shows the loop is running with floats
>> and not integers, interesting.
> 
> Maybe step size maxint//2 wil work with integers?

Yes, "maxint//2" does work and is what I am using for some tests, the issue was just a missing cast in the decimal part of the code, and my failure to realise the loop had been converted to the floating code path for another test. Also, for some reason I was thinking "maxint" would span the entire range of numbers, not just the positive ones.

The issue was that I forgot to cast the step size as unsigned before comparing to the remaining loop size. I had previously assigned the unsigned step size to a variable and simply forgot to copy the cast over when I refactored back into the if statement.

I will post the (hopefully) definitive patch file next along with a test script I created to test all these edge cases in both decimal and floating point contexts.

~Paige