Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Kelledin <kelledin+AXP@skarpsey.dyndns.org>
To: axp-list@redhat.com
Subject: Re: is this feature documented?
Date: Mon, 2 Dec 2002 18:08:28 -0600	[thread overview]
Message-ID: <200212021808.28428.kelledin+AXP@skarpsey.dyndns.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0212021828310.26163-100000@res104a-017.rh.rit.edu>

On Monday 02 December 2002 05:36 pm, Andrew A. Gill wrote:
> I was working with Kai Sterker (well, asking for help) on a
> floating point exception in the Adonthell program, when she
> noticed this interesting feature:
>
> 	[superluser@trystero superluser]$ cat fpe.cc
> 	#include <stdio.h>
>
> 	    int main(void)
> 	    {
> 	      int x = (int) (4/(float)0);
> 	      printf ("x = %i\n", x);
> 	    }
>
> 	[superluser@trystero superluser]$ g++ fpe.cc
> 	fpe.cc: In function `int main()':
> 	fpe.cc:5: warning: division by zero in `4 / 0.'
> 	[superluser@trystero superluser]$ ./a.out
> 	x = 0
>
> This is gcc version 3.2 20021115 (Red Hat Linux 8.0 3.2-14). 
> Should this be normal behavior?  Is this the expected output
> of standard C++?

I've seen things like this before; it's usually the developer's 
way of obtaining a bitwise IEEE754 representation of positive 
infinity (otherwise represented as macro HUGE_VAL or INFINITY 
from math.h).  I don't know what the developer was trying to do 
here, though.

The code behaves the same way on my system (ev56) as it does on 
yours, and I'm pretty sure my compiler is solid (gcc-3.2 release 
with a few bugfix patches).  So I would expect you're getting 
the correct output.

-- 
Kelledin
"If a server crashes in a server farm and no one pings it, does 
it still cost four figures to fix?"




  reply	other threads:[~2002-12-03  0:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-02 23:36 is this feature documented? Andrew A. Gill
2002-12-03  0:08 ` Kelledin [this message]
2002-12-03  8:20   ` Andrew A. Gill
2002-12-03  7:36 ` Falk Hueffner
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox