comp.lang.ada
 help / color / mirror / Atom feed
From: "Bobby D. Bryant" <bdbryant@mail.utexas.edu>
Subject: Re: Overhead for type conversions?
Date: Fri, 25 Jul 2003 01:12:41 -0600
Date: 2003-07-25T01:12:41-06:00	[thread overview]
Message-ID: <pan.2003.07.25.07.12.40.244666@mail.utexas.edu> (raw)
In-Reply-To: 3F209795.10303@attbi.com

On Fri, 25 Jul 2003 02:36:08 +0000, Robert I. Eachus wrote:

> 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.

There's not really any possibility of error, since any fp value is
potentially legitimate for either type.  In fact I have traditionally
gotten by with simply using float for both kinds of variable; I was just
thinking about separating the types for logical clarity and to make some
composite structures based on the two types incompatible.  Also I would
like to get away from using float directly so I'll have a single point of
change if I decide to start using long floats later on.

The only reason I'm asking about type conversion overhead in this case is
because my application already does many billions of multiplications over
the course of a run, and within a few years that number might rise to
trillions; and since I can live with float for both types I don't want to
saddle the application with a lot of avoidable overhead.

Thanks,
-- 
Bobby Bryant
Austin, Texas




  reply	other threads:[~2003-07-25  7:12 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
2003-07-25  7:12   ` Bobby D. Bryant [this message]
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