www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/12/23:38:00

Date: Thu, 12 Dec 1996 22:23:25 -0600 (CST)
From: Alan Hightower <alh AT engr DOT uark DOT edu>
To: Frank Frederiksen <ff AT kom DOT auc DOT dk>
cc: djgpp AT delorie DOT com
Subject: Re: Q: detecting valid floating point numbers?
In-Reply-To: <58gvqc$26p@newsfeed.cs.auc.dk>
Message-ID: <Pine.GSO.3.94.961212221741.8720B-100000@engr>
MIME-Version: 1.0

On 9 Dec 1996, Frank Frederiksen wrote:

> sometimes get a 'exiting due to SIGFPE' followed by a stack trace.
> 
> When we symify the program the first two lines are:
> __doprnt+1432
> _fprintf+105

compile the program with the -g option.  this adds debugging info that
will allow symify to print line numbers as well as functions.  It will
also allow you to use debuggers such as gdb to step through the program.

> So, is there a (simple)way of detecting if a floating point number
> is legal, before printing it, or do we have to investigate the
> numbers individually to see if they are valid numbers?

Unless bits 30-23 in a single precision number are all ones, it should be
a valid floating point representation.  The only exception might be if
fprintf or other specific fp functions barf on certain legal but unusual
bit patterns like denormals or -0, in which case bits 30-23 containing all
zeros might cause complications.
                  
                  /      +-----------------------------------------------+
   ///          / /        Alan Lee Hightower            University of
   \ //        /  /        Venture Systems, Inc.         Arkansas - Fay.
    \ ////   _/  /       +-----------------------------------------------+
     \_  ////    /
       \___/    /        "The world has yet to encompass true glory, glory
       /         \_          that can only be realized through BarneyDOOM!"
      /,)-_(  \_   \            
      (/   \\ / \\\\       ahightow AT comp DOT uark DOT edu           - Syntax Error
            //                 alh AT engr DOT engr DOT uark DOT edu 
           ((`                     ahightow AT alh DOT mslip DOT engr DOT uark DOT edu



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019