Iota

H. S. Teoh hsteoh at qfbox.info
Sat Aug 6 16:45:14 UTC 2022


On Sat, Aug 06, 2022 at 09:35:08AM -0700, Walter Bright via Digitalmars-d wrote:
> I haven't used iota much at all. But consider this. We all know
> exactly what integer arithmetic does, as long as it doesn't overflow.
> 
>     for (i = start; i < end; i += step)
> 
> I've been around the block enough times with floating point arithmetic
> that I would *not* use iota with it. The reason is simple enough - if
> each step is an addition, there's an extra rounding error added on
> with each increment.
> 
>     for (d = start; d < end; d += step)
> 
> as opposed to:
> 
>     for (d = start; d < end; (d = start + step * i, ++i))
> 
> which doesn't have roundoff error accumulation, and might even be
> faster.  How would I know which one iota uses?
> 
> I suggest seriously considering (for std2) having iota only work with
> integers. Floating point stuff can be done as a wrapper around iota.
> 
> But the core iota will be simple and understandable.

+1, iota with floating point was iffy to begin with.  Let's take it off
the table, start from a clean slate with integers only, and provide the
facilities for grafting everything else on using separate facilities.


T

-- 
What do you call optometrist jokes? Vitreous humor.


More information about the Digitalmars-d mailing list