From: Keith Thompson <kst-u@mib.org>
Subject: Re: How to check a Float for NaN
Date: Sun, 11 May 2008 15:00:55 -0700
Date: 2008-05-11T15:00:55-07:00 [thread overview]
Message-ID: <87wsm0o608.fsf@kvetch.smov.org> (raw)
In-Reply-To: 7xkVj.184851$D_3.118604@bgtnsc05-news.ops.worldnet.att.net
anon@anon.org (anon) writes:
> If you look at my first post on this topic and change the 16#FF000000#
> to 16#7F000000# (typo, forgot to adjust for the sign-bit) its basically
> what I have done except that I use a 64-bit sign integer instead of the
> Unsigned_64. In order to save coding time, did not want to add the
> extra statements. Plus, if it for a final (it that time of the year) they
> should be able add those lines.
[...]
You're using a value conversion. This converts, for example, the
Float value 3.0 to the Long_Long_Integer value 3. In your code, with
16#FF000000# changed to 16#7F000000#, this:
T : Long_Long_Integer := Long_Long_Integer ( N ) ;
...
if T > 16#7F000000# then
...
is essentially equivalent to this:
if T > 2130706432.0 then
Try isNan(2.0E9) and isNan(3.0E9).
You need an Unchecked_Conversion. You also need to make sure you
choose a floating-point and integer type of the same size, and to
allow for things like byte ordering (even if you're limiting the test
to systems that support IEEE floating-point, which is probably a
reasonable restriction since other floating-point formats may not
support NaNs at all).
--
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
next prev parent reply other threads:[~2008-05-11 22:00 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-30 10:27 How to check a Float for NaN Jerry
2008-04-30 10:47 ` christoph.grein
2008-04-30 10:50 ` christoph.grein
2008-04-30 15:02 ` Adam Beneschan
2008-04-30 20:33 ` Jerry
2008-04-30 23:23 ` Adam Beneschan
2008-05-01 1:00 ` Adam Beneschan
2008-05-01 19:52 ` Keith Thompson
2008-05-01 23:57 ` Jerry
2008-04-30 23:29 ` Randy Brukardt
2008-05-01 8:04 ` Stuart
2008-05-01 14:38 ` Adam Beneschan
2008-05-01 17:14 ` Stuart
2008-05-01 19:22 ` Randy Brukardt
2008-05-02 0:04 ` Jerry
2008-04-30 20:36 ` Jerry
2008-04-30 21:53 ` Adam Beneschan
2008-05-01 1:05 ` Jerry
2014-05-22 7:27 ` jan.de.kruyf
2014-05-22 8:09 ` Dmitry A. Kazakov
2014-05-22 9:24 ` Simon Wright
2014-05-22 9:48 ` Dmitry A. Kazakov
2014-05-22 15:28 ` Adam Beneschan
2014-05-22 16:31 ` Dmitry A. Kazakov
2014-05-22 23:33 ` Adam Beneschan
2014-05-23 7:38 ` Dmitry A. Kazakov
2014-05-23 21:39 ` Randy Brukardt
2014-05-27 8:35 ` Dmitry A. Kazakov
2014-05-27 12:35 ` Maurizio Tomasi
2014-05-27 15:53 ` Adam Beneschan
2014-05-27 22:35 ` Randy Brukardt
2014-05-27 22:59 ` Jeffrey Carter
2014-05-28 7:32 ` Dmitry A. Kazakov
2014-05-28 8:40 ` Maurizio Tomasi
2008-05-05 18:23 ` Martin Krischik
2008-05-05 20:49 ` Adam Beneschan
2008-05-06 18:09 ` Jerry
2008-05-06 18:45 ` Wiljan Derks
2008-05-06 22:18 ` Adam Beneschan
2008-05-07 22:56 ` Randy Brukardt
2008-05-07 22:56 ` Randy Brukardt
2008-05-07 23:20 ` Adam Beneschan
2008-05-09 7:24 ` Stephen Leake
2008-05-10 17:00 ` anon
2008-05-11 22:00 ` Keith Thompson [this message]
2008-05-12 2:01 ` anon
2008-05-09 19:49 ` anon
2008-05-10 2:36 ` Jerry
2008-05-10 3:53 ` anon
2008-05-10 6:24 ` christoph.grein
2008-05-10 8:05 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox