help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: (read (current-buffer)) returns an integer in a buffer full of text?


From: Kevin Rodgers
Subject: Re: (read (current-buffer)) returns an integer in a buffer full of text?
Date: Wed, 29 Nov 2006 11:22:00 -0700
User-agent: Thunderbird 1.5.0.8 (Windows/20061025)

Robert Thorpe wrote:
Sebastian Tennant wrote:
However, why does this happen:

 (with-temp-buffer
   (insert "586114704")
   (backward-word)
   (read (current-buffer)))

 => 49243792

Is there an integer limit relating to symbols somehow?

The function "read" will read whatever type it finds.  It will treat
586114704 as an integer.

Try the following:-
Type 586114704 into scratch and do C-x C-e straight afterwards.
The echo area will display 49243792.  This is because there is a limit
on integers in Emacs, they are 26-bits long.  This allows you to
represent -67108865 to 67108864 I think.

,----[ C-h v most-positive-fixnum RET ]
| most-positive-fixnum is a variable defined in `C source code'.
| Its value is 268435455
|
| Documentation:
| The largest value that is representable in a Lisp integer.
|
| [back]
`----

Emacs doesn't warn you when you exceed the limit unfortunately.

Generally if you want to do numerical things with Lisp you should use
another lisp such as Common Lisp.

--
Kevin





reply via email to

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