www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - assertion failure in std.range.iota

reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
import std.range;
import std.stdio;

void main()
{
    auto r1 = iota(0.0, 4.0, 0.03);  // ok
    auto r2 = iota(0.0, 3.0, 0.03);  //
core.exception.AssertError std.range(4001): Assertion failure
}

I want a range in steps of 0.03, beginning at 0.0 and ending at the
closest point to 3.0.

Line 4001 is:
assert(start + count * step >= end);

This assertion and the code above it make absolutely no sense to me.
The intention would be more clear if there was an error message, or
any documentation of the implementation, but no dice.
Aug 18 2011
parent reply Ali =?iso-8859-1?q?=C7ehreli?= <acehreli yahoo.com> writes:
On Fri, 19 Aug 2011 02:18:39 +0200, Andrej Mitrovic wrote:

 import std.range;
 import std.stdio;
 
 void main()
 {
     auto r1 = iota(0.0, 4.0, 0.03);  // ok auto r2 = iota(0.0, 3.0,
     0.03);  //
 core.exception.AssertError std.range(4001): Assertion failure }
 
 I want a range in steps of 0.03, beginning at 0.0 and ending at the
 closest point to 3.0.
 
 Line 4001 is:
 assert(start + count * step >= end);
An example of a floating point calculation error. (count * step) comes out to be less than end. :-/
 
 This assertion and the code above it make absolutely no sense to me. The
 intention would be more clear if there was an error message, or any
 documentation of the implementation, but no dice.
Ali
Aug 18 2011
parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6531
Aug 19 2011