unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Cc: emacs-devel@gnu.org
Subject: Re: Converting NaN to integer 0.
Date: Tue, 12 Feb 2002 10:46:29 -0600 (CST)	[thread overview]
Message-ID: <200202121646.KAA12400@eel.dms.auburn.edu> (raw)
In-Reply-To: <200202121524.g1CFOhK07421@aztec.santafe.edu> (message from Richard Stallman on Tue, 12 Feb 2002 08:24:43 -0700 (MST))

Richard Stallman wrote:

   Does anyone know what is the "correct" thing to do in this case
   according to IEEE?  Would returning NaN be correct?

The functiona ffloor, fceiling, ftruncate and fround all return (I
believe correctly) NaN when passed NaN.  They also return +INF or -INF
when passed those values.

The trouble with floor, ceiling, truncate and round seems to be that
these functions are supposed to return an integer, and NaN and the
infinities are floats, not integers.  So the problem is not what the
rounded value of NaN should be, that would clearly seem to be NaN, but
whether it makes sense to cast NaN to an integer.

I do not know what the IEEE floating point standard says about casting
these values to integers.  It is not guaranteed to say anything about
it, since it is a floating point standard.

The rounding functions in the GNU C library that return a floating
point number all behave like ffloor et al.  The rounding
functions that return integers (lrint and lround) seem to return
nonsense values when fed NAN or infinities.  So does trying to cast
NAN or an infinity to int.

floor, ceiling, truncate and round all produce an error when passed
infinity, I guess because the logical rounded value returned by ffloor
et al is not an integer.  Unless the IEEE standard says something
else, it would seem consistent to give an error message when NaN is
passed since the logical rounded value (NaN) returned by ffloor et al
is not an integer either.

It seems like somebody who expects NaN to be rounded to Nan would call
ffloor or similar, because he would not be insisting on an integer
result.


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


  reply	other threads:[~2002-02-12 16:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200202110253.g1B2r5E10557@swt40.swt.com>
2002-02-12 15:24 ` Converting NaN to integer 0 Richard Stallman
2002-02-12 16:46   ` Luc Teirlinck [this message]
2002-02-12 21:43   ` Paul Eggert
2002-02-12 23:46   ` Luc Teirlinck

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=200202121646.KAA12400@eel.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    --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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).