From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8af7fe40dc0a55ae X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!13g2000yql.googlegroups.com!not-for-mail From: "tmoran@acm.org" Newsgroups: comp.lang.ada Subject: Re: Restarting Tread: Why isn't this program working with Unchecked_Converstion Date: Thu, 15 Jan 2009 16:45:19 -0800 (PST) Organization: http://groups.google.com Message-ID: <951aac12-57d8-4420-b10a-9b265ea6d358@13g2000yql.googlegroups.com> References: 40239b21-b265-467f-9b27-5890fb2f4c67@w1g2000prm.googlegroups.com <6540d68e-2cc7-45aa-a5d2-ac16fa335822@i24g2000prf.googlegroups.com> NNTP-Posting-Host: 24.6.101.70 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1232066720 21709 127.0.0.1 (16 Jan 2009 00:45:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 16 Jan 2009 00:45:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 13g2000yql.googlegroups.com; posting-host=24.6.101.70; posting-account=8G1j8QkAAABAQTolGCWUf6Arl0PZneMD User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:4334 Date: 2009-01-15T16:45:19-08:00 List-Id: On Jan 15, 3:20=A0pm, ChristopherL wrote: > On Jan 15, 5:24=A0pm, Martin 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 :=3D 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.