mpz_get_si: possible undefined behaviour? [Was: Micro-GMP]
vincent at vinc17.net
Tue Dec 4 13:52:48 UTC 2018
On 2018-12-04 13:45:10 +0100, Torbjorn Granlund wrote:
> Pedro Gimeno <gmpdevel at formauri.es> writes:
> An assertion of LONG_MIN < -LONG_MAX should make the code safe in that case.
> Does The Standard even guarantee thet there are about as many negative
> and positive number?
> I am really worried that GMP might not properly on a machine where
> LONG_MIN = -17 while LONG_MAX = 2^32-18.
This is not possible. The C standard specifies the possible
* two's complement, which yields LONG_MIN = - LONG_MAX - 1
* ones' complement, which yields LONG_MIN = - LONG_MAX
* sign-magnitude, which yields LONG_MIN = - LONG_MAX
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the gmp-devel