[Cfp-interest 1979] Re: remquo( )
Paul Zimmermann
Paul.Zimmermann at inria.fr
Thu Apr 15 00:00:53 PDT 2021
Hi David,
is there any interest in defining (q,r) for y=0?
Another solution is to say that division by 0 is undefined,
and thus that (q,r) can be any value.
Paul
> Date: Wed, 14 Apr 2021 15:43:08 -0700 (PDT)
> From: David Hough CFP <pcfp at oakapple.net>
>
> The general property of
>
> x mod y -> (q,r)
>
> is that x = q*y + r, exactly; the difference between mod and remainder
> is how q is rounded to an integral value.
>
> So if q is integral and y is 0, then q is irrelevant and r is x.
>
> So which q? inf or NaN messes up the property.
>
> Offhand I'd say q could be zero.
>
> But looking at limiting cases of x mod y as y approaches 0, q gets bigger
> and bigger and r gets smaller and smaller. q does not approach 0 and r
> does not approach x. So from that point of view, q should be inf and
> r should be zero, both signed appropriately, but that means q*y should
> approach inf*0 which is indeterminate in general but should be defined to
> be x here! In exact cases when x is an integral multiple of y, then
> r is 0, and q*y is indeed exactly x.
More information about the Cfp-interest
mailing list