all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: integer overflow handling for most-negative-fixnum
Date: Sat, 21 Jul 2018 13:15:49 -0400	[thread overview]
Message-ID: <jwv8t64y0r6.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 83a7qkzyhz.fsf@gnu.org

>> ELISP> most-negative-fixnum
>> -2305843009213693952 (#o200000000000000000000, #x2000000000000000)
>> ELISP> #x2000000000000000
>> *** Read error ***  Arithmetic overflow error: "2000000000000000 (base 16)
>> is out of fixnum range; maybe set ‘read-integer-overflow-as-float’?"
>> ELISP> #x-2000000000000000
>> -2305843009213693952 (#o200000000000000000000, #x2000000000000000)
>> 
>> If the reader will not accept #x2000000000000000 as input then the value
>> of most-negative-fixnum as a non base10 number octal should have
>> negative sign to ensure consistent handling.

I don't see what this has to do with the reader's behavior on
#x2000000000000000.  The only problem I see above is how to *print*
a value like #x-2000000000000000, which is currently done incorrectly.

> Please don't forget the important use case of showing the hex
> representation of a negative number.  There are situations where I'd
> like to have "M-: -10 RET" display #x3ffffffffffffff6 rather than
> #x-0a.

IIRC this was discussed recently in the context of the introduction of
bignums.  I didn't follow the thread in its entirety, but to me both
behaviors are valid and desirable, so we need some way for the
programmer to choose which one to use when (i.e. print the negative
number as ... well ... a negative number even when printed in a non-10
base, or print it as a "bitfield" where the leading ones of the two's
complement representation are just more bits rather than a negative
sign)

> So I'd prefer we fixed the reader, if that's possible without breaking
> something important.

Not sure what "fix the reader" would do here.  Do you mean read
#x2000000000000000 as a negative number?  When/why/where would that be
a good idea?


        Stefan




  parent reply	other threads:[~2018-07-21 17:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19  2:39 integer overflow handling for most-negative-fixnum Andy Moreton
2018-07-20 22:10 ` Paul Eggert
2018-07-21  5:22   ` Helmut Eller
2018-07-21  9:47   ` Andy Moreton
2018-07-21 10:14     ` Eli Zaretskii
2018-07-21 13:06       ` Andy Moreton
2018-07-21 17:15       ` Stefan Monnier [this message]
2018-07-21 17:48         ` Paul Eggert
2018-07-21 18:12           ` Stefan Monnier
2018-07-23 19:18             ` Paul Eggert
2018-07-23 19:57               ` Stefan Monnier
2018-07-23 23:09                 ` Paul Eggert
2018-07-21 20:10           ` Helmut Eller
2018-07-21 21:02             ` Helmut Eller
2018-07-23 19:40             ` Paul Eggert
2018-07-21 18:10         ` Eli Zaretskii
2018-07-21 18:17           ` Paul Eggert
2018-07-21 18:23             ` Eli Zaretskii
2018-07-21 18:42           ` Stefan Monnier
2018-07-21 18:51             ` Eli Zaretskii
2018-07-21 20:42               ` Stefan Monnier
2018-07-21 12:42     ` Helmut Eller
2018-07-21 17:46     ` Paul Eggert
2018-07-23 11:49       ` Andy Moreton
2018-07-23 17:30         ` Paul Eggert
2018-07-23 21:11           ` Andy Moreton
2018-07-24 12:14             ` Andreas Schwab
2018-07-24 13:06               ` Andy Moreton
2018-07-21  9:49   ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv8t64y0r6.fsf-monnier+gmane.emacs.devel@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.