[tex-k] Wrong constant value?

Doug McKenna doug at mathemaesthetics.com
Tue Dec 5 16:01:40 CET 2017


Akiro -

TeX's code avoids treating the most negative twos-complement value for an integer as legal, so that any integer value can be negated safely.

Which could be why the "MIN" constants in this header file are all 1 higher than the actual most negative minimum value.  I'm not advocating changing those minimums, it's just that the maximum value for signed 8-bit bytes is 127, not 128, whereas the other maximums are not analogously overflowed.

Onward, into the fog ...

Doug McKenna


----- Original Message -----
From: "Akira Kakuto" <kakuto at fuk.kindai.ac.jp>
To: "Douglas McKenna" <doug at mathemaesthetics.com>, tex-k at tug.org
Sent: Tuesday, December 5, 2017 1:45:44 AM
Subject: Re: [tex-k] Wrong constant value?

Dear Douglas,

> In the kpathsea header file "c-minmax.h" the line
>
>    #define SCHAR_MAX 128
>
> seems to me to be incorrect.  I would think it should be
>
>    #define SCHAR_MAX 127

Probably, absolute values of MIN and MAX are reversed ;-
#define SCHAR_MIN (-127)
#define SCHAR_MAX 128
--->
#define SCHAR_MIN (-128)
#define SCHAR_MAX 127

Similarly
#define SHRT_MIN (-32767)
--->
#define SHRT_MIN (-32768)

#define INT_MIN (-2147483647)
--->
#define INT_MIN (-2147483648)

The are all unused in Kpathsea.

Best,
Akira


More information about the tex-k mailing list