Bug or feature? iota has different semantics for integer and float arguments

Arredondo arm.plus at gmail.com
Sat Jan 7 01:50:31 UTC 2023


On Saturday, 7 January 2023 at 00:52:20 UTC, Ali Çehreli wrote:
> Although that difference is a bug, iota does have a special 
> floating point implementation to prevent the accumulation of 
> floating point errors.

Thank you for this clarification Ali. I appreciate the fact that 
there is a specialized implementation for float types in an 
attempt to mitigate error accumulation.

After posting my previous message I became convinced that the 
behavior I was seeing was indeed a bug. The specialized fp 
implementation simply does not conform to the semantics specified 
in the documentation: "If begin < end && step < 0 or begin > end 
&& step > 0 or begin == end, then an empty range is returned."

The culprit is this assert in the `in` block of the fp 
implementation:

```
assert((end - begin) / step >= 0, "iota: incorrect startup 
parameters");
```

This effectively prevents iota from ever returning an empty 
range. Git blame points to a commit from March 2015. It's 
unbelievable to me this hasn't been fixed in almost 8 years.

Would anyone volunteer to file a bug report? I attempted to do it 
myself but I would need to create an account in the Issue 
Tracking System, and apparently it doesn't accept gmail addresses 
anymore? (facepalm).

Arredondo.


More information about the Digitalmars-d-learn mailing list