comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@acm.org>
To: comp.lang.ada@ada-france.org
Subject: Re: How unchecked conversion works?
Date: 14 Jan 2005 17:49:01 -0500
Date: 2005-01-14T17:49:01-05:00	[thread overview]
Message-ID: <mailman.54.1105742965.527.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <huRFd.84215$C94.3893@tornado.fastwebnet.it>

None <none@none.it> writes:

> well, I try to explain. I have those types for example
> 
> type fixed is delta 0.03 range -90.0..90.0
> for fixed'size use 16
> 
> and
> 
> type inte is range -32768..32767
> for inte'size use 16
> 
> 
> and a new function that renames unchecked_conversion to come from
> fixed to inte (probably an inefficient way, but I have to do this
> way), so I'd like to predict on paper which value of inte type
> corresponds to 89.09 for example: what kind of calculus should I do?
> This depends on something else? Thanks again!

If you are trying to control the exact representation of the fixed
point type, you need to specify the 'Small for the type:

for fixed'small use 0.03;

Then the least significant bit of 'fixed' represents a value of 0.03;
89.09 / 0.03 is 2970, so that is the result of the unchecked
conversion you are discussing.

This is explained in sections 3.5.9 and 3.5.10 of the Ada Reference
Manual, but it is somewhat obscure.

-- 
-- Stephe




      parent reply	other threads:[~2005-01-14 22:49 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
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 [this message]
replies disabled

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