[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Re: [q-lang-users] Re: IEEE float arithmetic

From: Abdulaziz Ghuloum
Subject: [Chicken-users] Re: [q-lang-users] Re: IEEE float arithmetic
Date: Wed, 21 Jun 2006 02:36:35 -0400
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.12) Gecko/20050915

John Cowan wrote:

Albert Graef scripsit:

But you want the code at least not to do any harm on systems with _no_ IEEE floats. I'm not sure, but couldn't dividing by 0.0 on such systems kill your program with SIGFPE?

I don't know.  I've never done serious floating-point work that
had to run on a non-IEEE system (everything I did on a PDP-8, PDP-11,
or pre-IEEE VAX was pretty much either integer-only or floats-as-integers,
as in most Basics).

Are there any processors nowadays that only support non-IEEE flonums?

Another point is that division is a much more costly operation than adding and subtracting.


But you don't need division to perform that test.  You can do the
following to be sure:

static double pos_inf = +1.0/0.0;
static double neg_inf = -1.0/0.0;
int isinf(double f){
  return f==pos_inf || f==neg_inf;

Now I have to say that gcc is brain damaged sometimes since it
constant-folds the 1.0/0.0 and -1.0/0.0 on PPC but performs the
actual division at runtime on Intel!  The above code should be
cheap on either although I'm not really impressed by the output
of gcc.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]