comp.lang.ada
 help / color / mirror / Atom feed
From: "tmoran@acm.org" <tmoran@acm.org>
Subject: Re: Restarting Tread: Why isn't this program working with Unchecked_Converstion
Date: Thu, 15 Jan 2009 16:45:19 -0800 (PST)
Date: 2009-01-15T16:45:19-08:00	[thread overview]
Message-ID: <951aac12-57d8-4420-b10a-9b265ea6d358@13g2000yql.googlegroups.com> (raw)
In-Reply-To: a8ef6226-db87-4c4c-b38e-9dbc77374f4c@t11g2000yqg.googlegroups.com

On Jan 15, 3:20 pm, ChristopherL <clusard...@aol.com> wrote:
> On Jan 15, 5:24 pm, Martin <martin.do...@btopenworld.com> wrote:
>
> > And that's assuming the Unchecked_Conversion works - double
> > check the actual sizes!
>
> In the debugger when I look at Float'Size it tells me 32.
> When I look at Short_integer1'Size it tells me 10, and for
> Short_integer2'Size it tell me 10.
>
> Chris L.

An Unchecked_Conversion just copies bits.  There's no way to copy 32
bits into something with room for only 10, and the compiler is
pointing this out now.  I suppose it could copy the leftmost 5 of the
32 bits, and the rightmost 5, and let you try to debug the result, but
that isn't The Ada Way.
Why don't you simply do a type conversion
  Result2 := Short_Integer2 (Result1);
There will then be a run-time check and, if the value in Result1 will
fit in a Short_Integer2, the assignment will take place.  If it won't
fit, it will raise an exception so you can debug your program.




  parent reply	other threads:[~2009-01-16  0:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-15 21:24 Restarting Tread: Why isn't this program working with Unchecked_Converstion Martin
     [not found] ` <a8ef6226-db87-4c4c-b38e-9dbc77374f4c@t11g2000yqg.googlegroups.com>
2009-01-16  0:45   ` tmoran [this message]
2009-01-16  8:02   ` Martin
     [not found] <83d19cd8-71ca-43c1-a3eb-05832290e565@r36g2000prf.googlegroups.com>
2009-01-15 21:22 ` Jeffrey R. Carter
     [not found]   ` <37daf0e6-39b8-4820-a7fc-b6c5decf1ed8@q19g2000yqi.googlegroups.com>
2009-01-16  0:22     ` Jeffrey R. Carter
     [not found] ` <40239b21-b265-467f-9b27-5890fb2f4c67@w1g2000prm.googlegroups.com>
2009-01-16  2:27   ` Adam Beneschan
     [not found]     ` <9069fcf7-4257-4439-ad4a-8d7c8c17f5cf@v5g2000pre.googlegroups.com>
2009-01-16 15:11       ` Ludovic Brenta
2009-01-16 16:23         ` Martin
     [not found]         ` <70172b19-360c-4eba-815c-ede747c3bcdf@w39g2000prb.googlegroups.com>
2009-01-16 17:24           ` Ludovic Brenta
2009-01-16 17:26           ` Martin
2009-01-16 17:34           ` Georg Bauhaus
2009-01-16 12:18 ` Stuart
2009-01-16 23:14   ` sjw
replies disabled

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