modulus redux

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Jul 13 05:51:06 PDT 2009


Michiel Helvensteijn wrote:
> Andrei Alexandrescu wrote:
> 
>> The  multiplicative expressions  are multiplication  (\ccbox{a  * b}),
>> division  (\ccbox{a  / b}),  and  remainder  (\ccbox{a  \% b}).   They
>> operate  on numeric types  only. The  result type  of either  of these
>> operations   is  same  as   the  type   of  \ccbox{true   ?  a   :  b}
>> (see~\S~\ref{sec:conditional-operator}).
> 
> "either of" means "one of two" or "both of two". You're talking about three
> operations, so I'd leave out "either of".

Ok, thanks.

> Also, while the (true ? a : b) thing may be true, is this really the
> clearest way to explain? Perhaps you should define a term to mean "common
> type of two operands" and use that to explain both typeof(a mulop b) and
> typeof(true ? a : b).

Turns out that defining the common type is rather involved. So I take 
time in the section dedicated to ?: and then I refer to it.

>> ...
>>
>> If such  a number  cannot be found,  \ccbox{a \%  b} yields the  Not A
>> Number (NaN) special value.
> 
> When is this? If b == 0? If b == NaN? Perhaps it would be better to be
> precise.

Oh there are quite a few situations, see e.g. 
http://msdn.microsoft.com/en-us/library/aa244368%28VS.60%29.aspx. I will 
add a few examples.


Andrei



More information about the Digitalmars-d mailing list