comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert Klungle" <bklungle@adelphia.net>
Subject: Re: how to safely convert from 32 to 16 bits?
Date: Sat, 4 Jun 2005 11:45:45 -0700
Date: 2005-06-04T11:45:45-07:00	[thread overview]
Message-ID: <5JednXDeC-wgaDzfRVn-hQ@adelphia.com> (raw)
In-Reply-To: uk6la101m.fsf@obry.net

Unless I misread the requestor, I think the following would more direct:

A : Integer_32;
B : Real_16;

B := Real_16(A);

cheers...bob

"Pascal Obry" <pascal@obry.net> wrote in message
news:uk6la101m.fsf@obry.net...
>
> di98mase@hotmail.com (Sebastian) writes:
>
> > 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?
>
> I don't see the problem.
>
>    A : Integer_32;
>    B : Integer_16:
>
>    B := Integer_16 (A);
>
> Since A is always between -180 and 180 there will be no exception raised.
>
> Pascal.
>
> -- 
>
> --|------------------------------------------------------
> --| Pascal Obry                           Team-Ada Member
> --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
> --|------------------------------------------------------
> --|              http://www.obry.net
> --| "The best way to travel is by means of imagination"
> --|
> --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595





  reply	other threads:[~2005-06-04 18:45 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 [this message]
2005-06-05  8:13     ` Pascal Obry
2005-06-05  1:24 ` David C. Hoos, Sr.
2005-06-05  5:03   ` Keith Thompson
replies disabled

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