PATCH: Bad signed int to long long conversion
vincent at vinc17.net
Thu Feb 9 17:47:32 CET 2012
On 2012-02-09 17:01:45 +0100, Torbjorn Granlund wrote:
> Strictly speaking, I don't think things like (unsigned long)(MIN_LONG)
> is well-defined C.
It is well-defined:
220.127.116.11 Signed and unsigned integers
1 When a value with integer type is converted to another integer
type other than _Bool, if the value can be represented by the
new type, it is unchanged.
2 Otherwise, if the new type is unsigned, the value is converted
by repeatedly adding or subtracting one more than the maximum
value that can be represented in the new type until the value
is in the range of the new type.60)
60) The rules describe arithmetic on the mathematical value, not
the value of a given type of expression.
18.104.22.168#2 describes the usual modular arithmetic rule.
Vincent Lefèvre <vincent at vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the gmp-bugs