Oh Dear

Michiel Helvensteijn m.helvensteijn.remove at gmail.com
Sun Jul 12 14:43:32 PDT 2009


Andrei Alexandrescu wrote:

> Thanks, Michiel. Here's what I have in TDPL. Is it 100% in sync with you?
> 
> =======================================
> ...
> 
> If~@b@  is  zero in  \ccbox{a  /  b} or  \ccbox{a  \%  b}, a  hardware
> exception   is  thrown.    The  sign\footnote{Sign,   not  signedness,
> i.e.,~the sign of  the actual value.}  of \ccbox{a  \% b} is always
> the same as  the sign of~@a at .  That is, \ccbox{a \%  b} is the closest
> number to  zero of the same sign  of~@a@

Now that I read it again (the last words there), this is not completely
accurate. I know I made the same mistake myself just now, but the remainder
has not necessarily the same sign as 'a', since it may be zero, which is
signless.

Of course, such a triviality won't hinder anyone's understanding, but you
may as well be accurate, no?

Some thing like "same sign as~@a@ (or zero)", perhaps? (Also note the
word 'as' instead of 'of', which is not strictly grammatically correct.)

> that must be  added to~@a@ to 
> make it divisible by~@b at .  For  example, \ccbox{-5 \% 2} and \ccbox{-5
> \% -2} both yield~\cc{-1}.

The rest of the information is accurate, but you still neglect to mention
the type of division. D uses truncated division. The quotient rounds
towards zero. In other words, it cuts off the fractional part of the
result.

Good luck with your book.

-- 
Michiel Helvensteijn




More information about the Digitalmars-d mailing list