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: a07f3367d7,fa37ee962bc4b00d X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!c18g2000prh.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Conversion from floating point to signed 16 bits Date: Tue, 19 May 2009 15:36:21 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <4a12ffa3$0$2853$ba620e4c@news.skynet.be> <5d240393-452e-46d8-bc55-e46901bb1d6f@d19g2000prh.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1242772581 2503 127.0.0.1 (19 May 2009 22:36:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 19 May 2009 22:36:21 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c18g2000prh.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5952 Date: 2009-05-19T15:36:21-07:00 List-Id: On May 19, 12:57=A0pm, "Jeffrey R. Carter" wrote: > Adam Beneschan wrote: > > > If your problem is that you're getting a Constraint_Error when the > > subtraction "U16 - 32768" has a negative result, you can convert U16 > > to some larger integer type before doing the subtraction: > > That wouldn't happen as written because the subtraction would use the bas= e type, > which is symmetrical (more or less) around zero. Ah, yes---brain freeze on my part. In that case, I'm with you... the code originally posted looks just fine to me. -- Adam