Re: Draft 2 is now available

From: Paul Floyd <Paul_Floyd_at_.....>
Date: Thu Jan 17 2008 - 01:49:33 PST
Hi David

>
> yes sorry, I missed making this correction.
>
> However I am not sure the below conditions work for all cases.
>
> If a > 0 and b < 0, then we also need to do the ceil().
>
> So I think the condition should be:
>
> if ( ( a / b ) < 0.0 )
>   a % b = a - ceil(a,b)*b;
> else
>   a % b = a - floor(a/b)*b;
>
> I should also make a mention that an error is raised if b == 0. I 
> think we
> should mention this simply because digital makes the point that b == 0 
> results
> in x being returned.
>
> Here is the rewrite of the section, if you are happy with it, I will 
> send it
> through to Stuart to include in draft 3. I also used a ternary as the 
> condition
> is not so bad now with just the check of a/b < 0.
>
> "
> The modulus operator, (for example a % b), gives the remainder when 
> the first
> operand is divided by the second, and thus is zero (0) when b divides a
> exactly. The result of a modulus operation takes the sign of the first 
> operand.
>
> It shall be an error to pass zero (0) as the second argument to the 
> modulus
> operator.
>
> For the case of the modulus operator where either argument is real, the
> operation performed is:
>
> a % b = ((a/b) < 0) ? (a - ceil(a,b)*b) : (a - floor(a,b)*b);
>
> "


You're right. This looks OK to me now.

Regards
Paul
-- 
Dr. Paul Floyd
Mentor Graphics Corporation



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Jan 17 01:50:14 2008

This archive was generated by hypermail 2.1.8 : Thu Jan 17 2008 - 01:50:29 PST