[Issue 23604] New: iota's floating point implementation does not conform to documentation
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jan 7 02:32:50 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23604
Issue ID: 23604
Summary: iota's floating point implementation does not conform
to documentation
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: acehreli at yahoo.com
The documentation at
https://dlang.org/library/std/range/iota.html
currently states
"The two-argument overloads have step = 1. If begin < end
&& step < 0 or begin > end && step > 0 or begin == end,
then an empty range is returned."
However, the implementation for floating point types does not match
documentation:
import std;
void test(T)() {
assert(iota(T(1), T(2), T(-1)).empty);
assert(iota(T(2), T(1)).empty); // By-default step==1
assert(iota(T(3), T(3)).empty); // By-default step==1
}
void main() {
test!int; // Produces empty ranges: GOOD
test!double; // asserts: BAD
}
See the following thread for further discussion:
https://forum.dlang.org/thread/rdbvirgshewaujtsscnp@forum.dlang.org
--
More information about the Digitalmars-d-bugs
mailing list