modulus redux

Don nospam at nospam.com
Tue Jul 14 01:53:07 PDT 2009


Walter Bright wrote:
> Don wrote:
>> Close, but that's technically not true in the case where abs(a/b) > 
>> long.max. (The integer doesn't have to fit into a 'long').
>>
>> In IEEE754, r= a % b is defined by the mathematical relation r = a  – 
>> b  * n , where n is the integer nearest the exact number a/b ; 
>> whenever abs( n  – a/b) = 0.5 , then n is even. If r == 0 , its sign 
>> is the same as a.
> 
> I hope you don't mind if I cut & paste this into the spec pages!

I've just put a comment on bug 3171,  I'm not sure that we really want 
IEEE behaviour. It obeys a == b * nearbyint(a/b) + a % b, but...



More information about the Digitalmars-d mailing list