Frank D. Engel, Jr. wrote:
CONST maxint = 32767; (* redefine *) minint = -32768;
To be pedantic, you might want to write `MinInt = -MaxInt;' since the standard demands a symmetric range of Integer.
Uh...
'-MaxInt' would imply -32767..32767, which wastes a potential stored value
That's according to the Pascal standards.
(and cannot accomidate interfacing with other languages, which do not have this restriction).
Irrelevant here. Chuck suggested a way to make sure code worked with 16 bit compilers. Interfacing with other languages is compiler-unportable, anyway.
'-MinInt' would imply -32768 (yes, negative; run the negation in 2's compliment and you will see what I mean).
Nope. This is not C, talking of bit patterns, but Pascal, talking of values. `-MinInt' is either 32768 or (if that value can't be represented because you're working on 16 bit types) an error.
By 'symmetric,' do you mean that the Pascal standard actually calls for the INTEGER type to have the same negative range as positive?
EP, 6.4.2.2:
1) All integral values in the closed interval from Âmaxint to +maxint shall be values of the integerÂtype.
Well, that doesn't say that *only* those values are values of the integerÂtype (unless I've missed another part), but if you want to be compiler-portable, you can only assume what's demanded in the standard, not what may be allowed.
Frank