Re: modulus redux

2009-07-14 Thread Walter Bright
Don wrote: 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... I saw that. Wild. But I think we should conform to IEEE behavior, even if it seems strange.

Re: modulus redux

2009-07-14 Thread Don
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 ;

Re: modulus redux

2009-07-13 Thread Walter Bright
Andrei Alexandrescu wrote: http://d.puremagic.com/issues/show_bug.cgi?id=3171 What are friends for? Ridiculing the cars my friends drive, of course!

Re: modulus redux

2009-07-13 Thread Andrei Alexandrescu
Walter Bright wrote: Andrei Alexandrescu 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'). But if real is 79-bit long (as on Intel), the largest integer that could fit without loss in 1 << 63, and

Re: modulus redux

2009-07-13 Thread Walter Bright
Andrei Alexandrescu 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'). But if real is 79-bit long (as on Intel), the largest integer that could fit without loss in 1 << 63, and that would fit in a lo

Re: modulus redux

2009-07-13 Thread Walter Bright
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

Re: modulus redux

2009-07-13 Thread Steven Schveighoffer
On Mon, 13 Jul 2009 08:51:06 -0400, Andrei Alexandrescu wrote: 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 onl

Re: modulus redux

2009-07-13 Thread Andrei Alexandrescu
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

Re: modulus redux

2009-07-13 Thread Andrei Alexandrescu
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'). But if real is 79-bit long (as on Intel), the largest integer that could fit without loss in 1 << 63, and that would fit in a long. Are you saying r could

Re: modulus redux

2009-07-13 Thread Michiel Helvensteijn
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

Re: modulus redux

2009-07-13 Thread Don
Andrei Alexandrescu wrote: Ok, here's how I rewrote the section on multiplicative operations. The text is hardly intelligible due to all formatting, sorry about that (but it looks much better in a specialized editor). Comments and suggestions welcome. \subsection{Multiplicative Expressions}

Re: modulus redux

2009-07-12 Thread Andrei Alexandrescu
TomD 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

Re: modulus redux

2009-07-12 Thread TomD
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 o

modulus redux

2009-07-12 Thread Andrei Alexandrescu
Ok, here's how I rewrote the section on multiplicative operations. The text is hardly intelligible due to all formatting, sorry about that (but it looks much better in a specialized editor). Comments and suggestions welcome. \subsection{Multiplicative Expressions} The multiplicative expressi