comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst-u@mib.org>
Subject: Re: How unchecked conversion works?
Date: Thu, 13 Jan 2005 22:28:04 GMT
Date: 2005-01-13T22:28:04+00:00	[thread overview]
Message-ID: <lnwtuhdkwc.fsf@nuthaus.mib.org> (raw)
In-Reply-To: MtzFd.82780$C94.78656@tornado.fastwebnet.it

None <none@none.it> writes:
> HI! I'd like to know what the compiler do for represent a simple float
> for example 34,4 delta 0.1 into an integer type for example range
> 1..10 using an Unchecked_Conversion. Thanks!

I'm not quite sure what you mean.  For one thing, a type declared with
"delta" is fixed-point, not floating-point.

Doing an Unchecked_Conversion from floating-point to integer is
unlikely to be useful.  An Unchecked_Conversion from fixed-point to
integer, on the other hand, might be; a fixed-point value is basically
a scaled integer, and Unchecked_Conversion might make sense if you
want to ignore the scaling.  (Nevertheless, you should spend some time
thinking about what problem you're trying to solve, and perhaps come
up with a cleaner way to do it.)

An Unchecked_Conversion call takes an operand of one type and pretends
that it's a value of another type.  This will typically be implemented
in machine code simply by doing nothing.  For example, if Conv is an
instance of Unchecked_Conversion, and X and Y are of appropriate types,
then this:

    X := Conv(Y);

will probably just copy the value of Y into X, just as

    X := Y;

would do if it were allowed.  (Presumably it isn't allowed because X
and Y are of incompatible types; otherwise you wouldn't need to use
Unchecked_Conversion.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.



  parent reply	other threads:[~2005-01-13 22:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-13 18:54 How unchecked conversion works? None
2005-01-13 21:22 ` Frank J. Lhota
2005-01-13 22:28 ` Keith Thompson [this message]
2005-01-14  0:17   ` Larry Kilgallen
2005-01-14 15:23 ` None
2005-01-14 15:55   ` Marius Amado Alves
2005-01-14 22:29     ` Keith Thompson
2005-01-14 23:15       ` Marius Amado Alves
2005-01-15  1:27         ` Keith Thompson
2005-01-15  2:15         ` Larry Kilgallen
2005-01-15 10:24           ` Marius Amado Alves
2005-01-15 12:02             ` Larry Kilgallen
2005-01-15 16:54               ` Nick Roberts
2005-01-16 16:14                 ` Larry Kilgallen
2005-01-16 16:41                   ` Jeffrey Carter
2005-01-16 20:52                     ` TCSEC security levels [was: How unchecked conversion works?] Nick Roberts
2005-01-17 15:57                       ` Larry Kilgallen
2005-01-17  0:34                     ` How unchecked conversion works? Larry Kilgallen
2005-01-17  1:29                       ` Jeffrey Carter
2005-01-17  4:20                         ` Larry Kilgallen
2005-01-15 18:24             ` Jeffrey Carter
2005-01-14 16:52   ` Mark H Johnson
2005-01-14 22:27     ` Keith Thompson
2005-01-14 22:49   ` Stephen Leake
replies disabled

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