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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.138.79 with SMTP id qo15mr3236806pab.34.1390495302614; Thu, 23 Jan 2014 08:41:42 -0800 (PST) X-Received: by 10.50.234.163 with SMTP id uf3mr986igc.4.1390495302013; Thu, 23 Jan 2014 08:41:42 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.linkpendium.com!news.linkpendium.com!news.snarked.org!newsfeed.news.ucla.edu!usenet.stanford.edu!rq2no366114pbb.1!news-out.google.com!vg8ni9igb.0!nntp.google.com!c10no2255361igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 23 Jan 2014 08:41:41 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <221ced1a-3a8d-4600-8e8e-b83e49652821@googlegroups.com> Subject: Re: How to round to the nearest fixed-point value? From: adambeneschan@gmail.com Injection-Date: Thu, 23 Jan 2014 16:41:42 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:18261 Date: 2014-01-23T08:41:41-08:00 List-Id: On Wednesday, January 22, 2014 11:02:59 PM UTC-8, Natasha Kerensikova wrote: > > > I'm pretty sure this is a compiler bug. Since Low'Small is a multiple of High'Small, you can work around it by changing the definition of Convert to > > > return Low (Value + Low'Small / 2); > > > (Low'Small is a universal real and therefore Low'Small/2 will be interpreted as a value of type High. The type conversion to Low will truncate.) > > > > I have been considering that, however it seems type conversion truncates > towards zero, so the expression above is only correct for positive > Values, while Low'Small/2 should be subtracted when Value is negative. > > Or am I missing something? My fault, I forgot about negative values. -- Adam