From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,772ddcb41cd06d5b X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.germany.com!aioe.org!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: How to check a Float for NaN Date: Sun, 11 May 2008 15:00:55 -0700 Organization: None to speak of Message-ID: <87wsm0o608.fsf@kvetch.smov.org> References: <3132e38d-18bb-4890-9cec-31056ac6e3ba@x19g2000prg.googlegroups.com> <12227360.svS57WvVVs@linux1.krischik.com> <7xkVj.184851$D_3.118604@bgtnsc05-news.ops.worldnet.att.net> NNTP-Posting-Host: aVIvKdUSjN4PsAbmZ6BGcQ.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@aioe.org Cancel-Lock: sha1:GfXEdYYBFPWxlIhdhsTkZoCIBuY= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Xref: g2news1.google.com comp.lang.ada:43 Date: 2008-05-11T15:00:55-07:00 List-Id: 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) Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"