comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst-u@mib.org>
Subject: Re: how to safely convert from 32 to 16 bits?
Date: Sun, 05 Jun 2005 05:03:43 GMT
Date: 2005-06-05T05:03:43+00:00	[thread overview]
Message-ID: <lnd5r175u9.fsf@nuthaus.mib.org> (raw)
In-Reply-To: mailman.7.1117934644.17633.comp.lang.ada@ada-france.org

"David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> writes:
> "Sebastian" <di98mase@hotmail.com> writes:
>> Ho do I convert a larger variable like Integer to an smaller type
>> without loosing any data?
>> What I would like to do is:
>> I have a variable of Integer_32 size, I also know that the value is
>> always between -180 and 180. I would like to assign that value to a 16
>> bits Real type.
>> How can that be done without loosing any data?
> 
> What compiler and hardware are you using that has a 16-bit Real type?

It could be a fixed-point type.  If so, knowing that it's 16 bits
doesn't necessarily tell us that it can hold all values from -180 to
180.

To the original poster: How exactly is Real declared?

If the target type can hold all the expected values, just do a
conversion.  If it can't, there's nothing you can do to make all the
values fit (unless you change the type).

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



      reply	other threads:[~2005-06-05  5:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-04 17:23 how to safely convert from 32 to 16 bits? Sebastian
2005-06-04 17:53 ` Pascal Obry
2005-06-04 18:45   ` Robert Klungle
2005-06-05  8:13     ` Pascal Obry
2005-06-05  1:24 ` David C. Hoos, Sr.
2005-06-05  5:03   ` Keith Thompson [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