www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3000] New: iota should work with floats

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3000

           Summary: iota should work with floats
           Product: D
           Version: 2.030
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dsimcha yahoo.com


import std.range;

void main() {
    auto foo = iota(0.0L, 10.0L, 1.0L);
}

The above doesn't compile and results in a bunch of long errors that aren't
particularly useful for diagnosing the cause of the problem.  The real problem
is
line 2089, range.d:

return take((end - begin + step - 1) / step, Seq(tuple(begin, step), 0u));

The problem is that, if the arguments to iota are floats, not ints, the number
of elements take() is told to take is a float, not an int.  This can be fixed
trivially by changing that line to:

return take(cast(size_t) ((end - begin + step - 1) / step), Seq(tuple(begin,
step), 0u));

Also, take() should probably use a ulong, not a size_t.  I could picture
someone wanting to run a long monte carlo simulation, for example, by taking
more than 4 billion elements from an infinite range of random numbers.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 17 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3000


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|bugzilla digitalmars.com    |andrei metalanguage.com




-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 17 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3000


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED





10:02:24 PDT ---
Fixed in future 2.032 (and checked in for the impatient).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 07 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3000


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |braddr puremagic.com
         Resolution|FIXED                       |





PDT ---
Should the examples be updated to include one for floats, maybe?

Also, how about adding a bit more sanity checking such as B, E, and S are all
numeric types?

Also, what does 'iota' stand for?  I keep reading it as 'itoa' which is
obviously wrong.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 09 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3000


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED





12:11:32 PDT ---

 Should the examples be updated to include one for floats, maybe?
Done. Also found and fixed a couple of issues with negative ranges.
 Also, how about adding a bit more sanity checking such as B, E, and S are all
 numeric types?
B and E can be pointers. I did add a check that should eliminate nonsensical calls.
 Also, what does 'iota' stand for?  I keep reading it as 'itoa' which is
 obviously wrong.
It's an actual word of which meaning in the current context I borrowed from some STL implementations (http://www.sgi.com/tech/stl/iota.html). Bug fixed and checked in; the fix will come in dmd 2.032. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 11 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3000






PDT ---
I thought that might be the case (regarding the name), but it wasn't obvious. 
And I still keep reading it with the o and t reversed. :)

Thanks for the updates.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 11 2009