comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: Overhead for type conversions?
Date: Fri, 25 Jul 2003 02:36:08 GMT
Date: 2003-07-25T02:36:08+00:00	[thread overview]
Message-ID: <3F209795.10303@attbi.com> (raw)
In-Reply-To: pan.2003.07.25.01.01.43.5699@mail.utexas.edu

Bobby D. Bryant wrote:

> and given that run-time range checks are enabled, should I expect my
> compiler to execute range checking code for each f1*f2 multiplication,
> or will the compiler conclude from the definitions that the two types
> are always convertible without error regardless of the specific value,
> and thus not generate any code for a range check?
> 
> (In practice the compiler is GNAT.)

GNAT chooses IEEE representation for Float with non-signalling NaNs.  In 
other words there are operation which will generate +infinity or 
-infinity but no constraint checks.

Of course this means that if you really want to force a Constraint_Error 
you have to assign a Float to a variable with a constraint.  To 
reference a huge amount of sound and fury going on right now, something 
like:

   BH := Short_Integer(Some_Float_Value);

will do just fine. (But then you have to decide how the exception should 
be handled. ;-)

-- 

                                                        Robert I. Eachus

�In an ally, considerations of house, clan, planet, race are 
insignificant beside two prime questions, which are: 1. Can he shoot? 2. 
Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and 
Steve Miller.




  reply	other threads:[~2003-07-25  2:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-25  1:01 Overhead for type conversions? Bobby D. Bryant
2003-07-25  2:36 ` Robert I. Eachus [this message]
2003-07-25  7:12   ` Bobby D. Bryant
2003-07-25 15:34 ` Matthew Heaney
2003-07-25 18:28 ` Randy Brukardt
2003-07-26 15:54 ` Nick Roberts
2003-07-26 16:01   ` Warren W. Gay VE3WWG
2003-07-26 23:39     ` Bobby D. Bryant
2003-07-27 13:41       ` Loop Optimisation [was: Overhead for type conversions?] Nick Roberts
replies disabled

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