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

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

Converting NaN to integer 0.


From: Luc Teirlinck
Subject: Converting NaN to integer 0.
Date: Sun, 10 Feb 2002 21:36:34 -0600 (CST)

This bug report will be sent to the Free Software Foundation,
 not to your local site managers!!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

In GNU Emacs 20.7.1 (sparc-sun-solaris2.8, X toolkit)
 of Thu Apr 12 2001 on eel
configured using `configure  --prefix=/home/teirllm/emacshome'

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

truncate, floor, ceiling and round all convert 0.0e+Nan to 0.  (See
the ielm run below.)  Maybe there is some very good reason for this
that I am missing.  If not, then it would seem to be a lot better to
return an error message than the value 0.  (This is exactly what
happens if the same functions get passed infinity.)

I do not know of any instance where one might deliberately pass NaN to
an integer rounding function.  This would only seem to happen as
result of either a programming error or invalid user input. It would
seem better to point attention to the bug or invalid input rather than
sweep all evidence of it under the carpet by removing the NaN value.
In C a value of NAN usually raises an exception that can be checked at
any time.  To my knowledge, there is no analogue in Elisp and the
value Nan might be the only indication that something went wrong.

Copy of ielm run:

*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (truncate 0.0e+NaN)
0
ELISP> (truncate 8.9e+NaN)
0
ELISP> (floor 0.0e+NaN)
0
ELISP> (ceiling 0.0e+NaN)
0
ELISP> (round 0.0e+NaN)
0
ELISP> (floor (sqrt -9))
0
ELISP> (floor 1.0e+INF)
*** Eval error ***  Arithmetic range error: "floor", 1.0e+INF
ELISP> (emacs-version) (emacs-version)
"GNU Emacs 21.1.90.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll
bars)\n of 2002-02-10 on swt40.swt.com"
ELISP> 

Note that the ielm run is on Emacs21.1.90.1, but this problem (if it
is one) was not introduced in that version.  It occurs in 20.7 as well.



Recent input:
O B ESC O B ESC O B ESC O B ESC O B ESC O B ESC O B 
ESC O B ESC O B ESC O B ESC O B ESC O B ESC O B ESC 
O B ESC O B ESC O B ESC O B ESC O B ESC O B ESC O B 
ESC O A ESC O A ESC O A ESC O A ESC O A ESC O A ESC 
O A ESC O A ESC O A RET C-x k RET C-x 1 ESC x r - e 
- b RET

Recent messages:
(No new mail has arrived)
Quit
Buffer is read-only: #<buffer RMAIL>
Quit
Command attempted to use minibuffer while in minibuffer
Quit
Auto-saving...
Auto-saving...done
Quit
Undo! [2 times]



reply via email to

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