[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: integer exponentiation with negative exponent**
**From**: Roberto Ierusalimschy <roberto@...>
**Date**: Tue, 20 May 2014 10:30:23 -0300

> Until twenty minutes ago that's what I thought too. But Section 3.3.5 of the 1988 draft ANSI C standard:
>
> "If either operand is negative, whether the result of the / operator is the largest integer less than the algebraic quotient or the smallest integer greater than the algebraic quotient is implementation-defined, as is the sign of the result of the % operator. If the quotient a/b is representable, the expression (a/b)*b + a%b shall equal a."
>
> [...]
>
> My head hurts.
Mine too! Now that I know it, I have seen that "C: A Reference Manual"
also says so.
-- Roberto