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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: border2.nntp.ams2.giganews.com!backlog4.nntp.ams3.giganews.com!backlog4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: Re: How to round to the nearest fixed-point value? Date: Fri, 24 Jan 2014 09:58:27 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Date: Fri, 24 Jan 2014 09:58:27 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="31d6bde745a337034b005384ef225743"; logging-data="11420"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dAzYbia3DoQd2K8ORH4ed" User-Agent: slrn/0.9.9p1 (FreeBSD) Cancel-Lock: sha1:eKnzKZnqrUz4I1fFNx57ua/Igsk= X-Original-Bytes: 1777 Xref: number.nntp.dca.giganews.com comp.lang.ada:184539 Date: 2014-01-24T09:58:27+00:00 List-Id: Hello, On 2014-01-22, Natasha Kerensikova wrote: > function Convert (Value : High) return Low is > begin > return Low'Round (Value); > end Convert; In case anyone is interested, the following rewrite works around the problem: function Convert (Value : High) return Low is begin return Low'Round (Value * 1.0); end Convert; I would have thought that the optimizer would have quickly brought both version to the same generated code, but from -O0 to -O3 I get the correct rounding with the latter but not with the former. I guess that's enough to conclude there is a compiler bug somewhere (or a weird bug in the language). I'll have to send that to AdaCore... Natasha