emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: integer overflow handling for most-negative-fixnum


From: Stefan Monnier
Subject: Re: integer overflow handling for most-negative-fixnum
Date: Sat, 21 Jul 2018 16:42:03 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> When the user wrote #x3fffffffffffffff to mean "the positive number
>> written as 3fffffffffffffff in hexadecimal"
> There's no such positive number, at least not as fixnum.

That's no excuse to turn around and return a negative number instead.
If I try to read too large a decimal number, Emacs signals an
`overflow-error` instead of returning a negative number, so it makes
sense to do the same for hexadecimal numbers.

>> You can only read it as "-1" based on an assumption of fixed-width
>> two's-complement representation but the bitwidth of Emacs numbers is
>> something that can change between Emacs versions and
>> compilation options.
> I'm talking about an Emacs with 64-bit EMACS_INT.

Right, but the reader is designed to `read` files which are usually not
specific to a given build (historically, there have been some
build-dependence on the result of `read`, but we've generally
considered them as bugs or misfeatures).


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]