Oh Dear

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Jul 12 15:42:52 PDT 2009


Michiel Helvensteijn wrote:
> Andrei Alexandrescu wrote:
> 
>> \dee\ also defines modulus for  floating-point numbers in the same way
>> as the  IEEE~754  standard.  When  at least one  of @a@  and @b@  is a
>> floating-point value in \cc{a \%  b}, the result is the floating-point
>> number @r@ satisfying the relation \cc{a = b * n + r}, where @n@ is an
>> integer\footnote{``integer'' in  the mathematical sense  here} and @r@
>> is a positive number less than @b@'s absolute value.
> 
> Oh, about this part. I left it out because it's not about integer division,
> but while I'm at it anyway.
> 
> I believe you wanted the word "non-negative" there, instead of "positive".
> However, I just ran the following test:
> 
> ----------------------------
> writefln(5.0%2.0);
> writefln(5.0%(-2.0));
> writefln((-5.0)%2.0);
> writefln((-5.0)%(-2.0));
> ----------------------------
> 
> it outputs:
> 
> ----------
> 1
> 1
> -1
> -1
> ----------
> 
> So the remainder can still become negative, it seems. Same as with integer
> modulo. I would expect this consistency, but your paragraph there says
> something different.
> 

Walter?

Andrei



More information about the Digitalmars-d mailing list