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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news1.google.com!news.glorb.com!wn13feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: How to check a Float for NaN Reply-To: anon@anon.org (anon) References: <3132e38d-18bb-4890-9cec-31056ac6e3ba@x19g2000prg.googlegroups.com> <12227360.svS57WvVVs@linux1.krischik.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: <7xkVj.184851$D_3.118604@bgtnsc05-news.ops.worldnet.att.net> Date: Sat, 10 May 2008 17:00:51 GMT NNTP-Posting-Host: 12.65.198.7 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1210438851 12.65.198.7 (Sat, 10 May 2008 17:00:51 GMT) NNTP-Posting-Date: Sat, 10 May 2008 17:00:51 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:34 Date: 2008-05-10T17:00:51+00:00 List-Id: 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. And because float is normally defined by the IEEE-754 as a 32-bit number it will fix into a 64-bit integer without raising a Constraint_Error. The size of Long_Long_Integer is at least 64-bit signed integer on a 32/64 bit machines. NaN := range 2#0111_1111_1111_0000_0000_0000_0000_0000# .. 2#1111_1111_1111_1111_1111_1111_1111_1111# ; In <12227360.svS57WvVVs@linux1.krischik.com>, Martin Krischik writes: >Jerry wrote: > >> How would one check a Float or Long_Float if it has value NaN? The >> only ways that I can come up with are to import a C function (isnan, I >> think) or to write Long_Float'image(Some_Float) to a string and >> examine the first three characters to see if they are "NaN" (and that >> seems to be a GNAT implementation choice so might not be portable, >> which is OK for my use). > >How about an Unchecked Conversion to an Unsigned_64 and comparing >>2#0111_1111_1111_0000_0000_0000_0000_0000# > >Note that it's '>' as 2#0111_1111_1111_0000_0000_0000_0000_0000# is positive >infinity. > >Martin >-- >mailto://krischik@users.sourceforge.net >Ada programming at: http://ada.krischik.com