From: randhol+abuse@pvv.org (Preben Randhol)
Subject: Re: Catching NaN .. not a number
Date: Sat, 5 May 2001 17:58:42 +0000 (UTC)
Date: 2001-05-05T17:58:42+00:00 [thread overview]
Message-ID: <slrn9f8fv0.17m.randhol+abuse@kiuk0156.chembio.ntnu.no> (raw)
In-Reply-To: 9d1eai$3nf$1@eol.dd.chalmers.se
On 5 May 2001 17:46:58 GMT, Staffan Dittmer wrote:
> Did some calcualtions during the night and
> ended up with an output file full of NaN - due to
> overflow when calculating a factorial.
>
> A bit surprised by this since I thought a Constraint Error
> would be raised.
>
> So, how do I catch a NaN result ?
Which compiler? When you say calculating factorial, do you use integer?
If so and If you use GNAT you have to compile your program with this
switch:
`-gnato'
Enables overflow checking for integer operations. This causes
GNAT to generate slower and larger executable programs by adding
code to check for both overflow and division by zero (resulting in
raising `Constraint_Error' as required by Ada semantics). Note
that the `-gnato' switch does not affect the code generated for
any floating-point operations; it applies only to integer
operations. For floating-point, GNAT has the `Machine_Overflows'
attribute set to `False' and the normal mode of operation is to
generate IEEE NaN and infinite values on overflow or invalid
operations (such as dividing 0.0 by 0.0).
--
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
�For me, Ada95 puts back the joy in programming.�
next prev parent reply other threads:[~2001-05-05 17:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-05 17:46 Catching NaN .. not a number Staffan Dittmer
2001-05-05 17:58 ` Preben Randhol [this message]
2001-05-05 18:28 ` Staffan Dittmer
2001-05-05 21:50 ` Keith Thompson
2001-05-07 21:40 ` Stephen Leake
2001-05-08 1:37 ` David C. Hoos, Sr.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox