Can we assume that -LLONG_MAX (negation of LLONG_MAX ) belongs to the long long range?
Can we assume that if LLONG_MIN < -LLONG_MAX , then LLONG_MIN == -LLONG_MAX - 1 ?
Is this guaranteed by the standard or only all actual devices provide either LLONG_MIN == -LLONG_MAX - 1 or LLONG_MIN == -LLONG_MAX ?
These three statements are true when the implementation uses one of 2 additions, 1 addition or sign and magnitude to represent signed integer types. -LLONG_MAX is in the long long range in all three patterns, and LLONG_MIN is -LLONG_MAX (1 addition, sign and magnitude, and possibly 2 additions) or -LLONG_MAX-1 (possibly 2 additions). 2 complementary machines can use this extra value as a trap representation, just as 1 device with padding and signs and values can use negative zero as a trap representation. Therefore, the answer to your questions is yes, if the standard provides that the implementation uses one of these schemes.
The C standard (to which the C ++ standard prefers in many places) provides either 2 additions, 1 addition, or a sign and value:
C11 6.2.6.2 Integer types :
If the sign bit is one, the value must be changed in one of the following ways:
- the corresponding value with the sign bit 0 is negated (sign and value),
- the sign bit has the meaning - (2M) (two additions),
- the sign bit has the value - (2M - 1) (one addition).
The C ++ standard looks a little more open:
C ++ 14 3.9.1 The main types:
Representations of integral types must determine values using a pure binary numbering system 51 . [Example: this international standard allows 2s aggregation, 1s complements, and subscription values for integral types. -end example]
Footnote 51, which defines what “pure binary numbering system” means, means to exclude decimal systems as well as offset systems (where 0 is not all bits zero):
51) A positional representation for integers that uses the binary digits 0 and 1, in which the values represented by consecutive bits are additive, start from 1 and multiply by sequential integral power 2, except, possibly, for bits with the highest position.
Practically speaking, all that remains is 2 additions, 1 addition and sign and magnitude: the same schemes that are provided by the standard C. I doubt that the seller will touch on a machine that uses the new 21st century scheme to represent integers and somehow meets the letter of the law of the C ++ standard (but, therefore, is not consistent with C).