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: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.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> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Sat, 10 May 2008 03:53:54 GMT NNTP-Posting-Host: 12.65.24.11 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1210391634 12.65.24.11 (Sat, 10 May 2008 03:53:54 GMT) NNTP-Posting-Date: Sat, 10 May 2008 03:53:54 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:5758 Date: 2008-05-10T03:53:54+00:00 List-Id: Reference Microsoft and "isnan.asm" from http://www.visionlab.uncc.edu/websvn/filedetails.php?repname=toolchain&path=%2Fvendor%2Fvdsplibs%2Fcurrent%2Flibdsp%2Fisnan.asm&rev=1693&sc=1 The only mistake is that T > 16#7F000000# because I forgot to adjust for the the sign bit because NaN can have a valid sign set. This work because in Intel the NaN is set by forcing bits 30-24 to 1 aka 16#7F000000# The T : Long_Long_Integer := Long_Long_Integer ( N ) ; moves the bit-value of N a 48-bit float to a Long_Long_Integer (T) without conversion. In , Jerry writes: >On May 9, 12:49=A0pm, a...@anon.org (anon) wrote: >> =A0 -- >> =A0 -- Nan is define to be greater than value of hex 16#FF000000# >> =A0 -- >> >> =A0 function isNan ( N : Float ) return Boolean is >> >> =A0 =A0 =A0T : Long_Long_Integer :=3D Long_Long_Integer ( N ) ; >> >> =A0 =A0 begin >> =A0 =A0 =A0 if T > 16#FF000000# then >> =A0 =A0 =A0 =A0 return True ; >> =A0 =A0 =A0 else >> =A0 =A0 =A0 =A0 return False ; >> =A0 =A0 =A0 end if ; >> =A0 =A0 end ; >> >> In <3132e38d-18bb-4890-9cec-31056ac6e...@x19g2000prg.googlegroups.com>, Je= >rry writes: >> >> >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). >> >> >Jerry > >No offense to anon, but does this work? Does anyone know of a >reference for this definition of a NaN? > >Also, wondering how one might detect an Inf. > >It seems that there is enough information in this thread to begin >writing a little package to deal with some of these things. > >Thanks for all the great tips, BTW. > >Jerry