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 14:42:32 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> Not sure what "fix the reader" would do here.  Do you mean read
>> #x2000000000000000 as a negative number?
> Yes.  More importantly, I'd like it to read #x3fffffffffffffff as -1.

Hmm... me don't like that at all.

>> When/why/where would that be a good idea?
> When wouldn't it be a good idea?

When the user wrote #x3fffffffffffffff to mean "the positive number
written as 3fffffffffffffff in hexadecimal" (which as far as I know is
what "#x3fffffffffffffff" means in Elisp).

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.  [ Especially since the leading digit is "3"
rather than "f", which means it can only be treated as -1 under the
assumption that the author really knew *exactly* how many bits his
particular Emacs build uses for integers.  ]


        Stefan



reply via email to

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