Why is INT_MIN in limits.h defined as -2,147,483,647-1, not either -2,147,483,648 or 0x80000000?

-10

In Computer Systems: a Programmer's Perspective:

Writing TMin in C In Figure 2.19 and in Problem 2.21, we carefully wrote the value of TMin32 as -2,147,483,647-1. Why not simply write it as either -2,147,483,648 or 0x80000000? Looking at the C header file limits.h, we see that they use a similar method as we have to write TMin32 and TMax32:

/* Minimum and maximum values a ‘signed int’ can hold. */
#define INT_MAX 2147483647
#define INT_MIN (-INT_MAX - 1)

Unfortunately, a curious interaction between the asymmetry of the two’s-complement representation and the conversion rules of C forces us to write TMin32 in this unusual way. Although understanding this issue requires us to delve into one of the murkier corners of the C language standards, it will help us appreciate some of the subtleties of integer data types and representations.

What is the "interaction between the asymmetry of the two’s-complement representation and the conversion rules of C"?

Why does it force us to write TMin32 i.e. INT_MIN in this unusual way?

c
signed-integer
asked on Stack Overflow Oct 10, 2020 by Tim • edited Oct 10, 2020 by Tim

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0