January 07, 2023 [Issue 23604] New: iota's floating point implementation does not conform to documentation | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: acehreli@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 -- |
Copyright © 1999-2021 by the D Language Foundation