[Issue 15720] iota(long.max, long.min, step) does not work properly
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Mar 20 15:49:30 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=15720
Ender KaShae <astrothayne at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |astrothayne at gmail.com
--- Comment #1 from Ender KaShae <astrothayne at gmail.com> ---
This happens because the operation to compute the length is
```
unsigned((start - stop) / -step)
```
but `long.max - long.min` overflows the long and results in -1.
The reason it works for a step of 1 is that -1 is cast to a ulong, which
results in the maximum value of ulong (18446744073709551615).
Maybe this could be fixed by casting to the unsigned type before dividing by
the step.
--
More information about the Digitalmars-d-bugs
mailing list