std.range.iota enhancement: supporting more types (AKA issue 10762)

Craig Dillabaugh cdillaba at cg.scs.carleton.ca
Tue Dec 24 10:56:01 PST 2013


On Tuesday, 24 December 2013 at 17:10:53 UTC, Andrei Alexandrescu
wrote:
> On 12/24/13 5:09 AM, Joseph Rushton Wakeling wrote:
>> On 24/12/13 13:58, monarch_dodra wrote:
>>> I think you are missing the point of what happens if the step 
>>> is not 1
>>> (or if
>>> the passed in type can have fractional input). EG:
>>>
>>> iota(0, 105, 10);
>>> or
>>> iota(0, 10.5);
>>>
>>> In this case, "back" should be 100, and not 95. To compute 
>>> back, you
>>> need to be
>>> able to evaluate length, and to add length*inc to front.
>>
>> Oh, snap.  Have we been working on the same problems for too 
>> long? :-)
>
> The integral cases are easy. We need to crack the floating 
> point case: given numbers low, up, and step, what's the closest 
> number smaller than up that's reached by repeated adds of step 
> to low?
>
> Andrei

Doesn't think work, or am I missing something?

low + floor( (up-low)/step ) * step


More information about the Digitalmars-d mailing list