On Tue, Dec 24, 2013 at 11:35:49AM -0800, Andrei Alexandrescu wrote:
> On 12/24/13 10:56 AM, Craig Dillabaugh wrote:
> >On Tuesday, 24 December 2013 at 17:10:53 UTC, Andrei Alexandrescu
> >wrote:
[.[..]
> >>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
> 
> I doubt it's anything as simple as that. The magnitudes of up, low,
> and step must be taken into account.
[...]

What about low + fmod(up-low, step)*step? Is that better? (Assuming that
fmod would take relative magnitudes into account, of course.)


T

-- 
Only boring people get bored. -- JM

Reply via email to