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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!l35g2000vba.googlegroups.com!not-for-mail From: sjw Newsgroups: comp.lang.ada Subject: Re: conversions between fixed-point types Date: Fri, 25 Sep 2009 13:41:15 -0700 (PDT) Organization: http://groups.google.com Message-ID: <35adcbc7-dec6-45ae-bf80-1ebb7a058507@l35g2000vba.googlegroups.com> References: <4abc8389$1_1@glkas0286.greenlnk.net> NNTP-Posting-Host: 82.30.110.254 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1253911275 26473 127.0.0.1 (25 Sep 2009 20:41:15 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 25 Sep 2009 20:41:15 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l35g2000vba.googlegroups.com; posting-host=82.30.110.254; posting-account=_RXWmAoAAADQS3ojtLFDmTNJCT0N2R4U User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8475 Date: 2009-09-25T13:41:15-07:00 List-Id: On Sep 25, 9:47=A0am, "Stuart" wrote: > "Adam Beneschan" wrote in message > > news:c8af7daf-9f00-4dbb-ad0d-9ca65e0a83d6@f18g2000prf.googlegroups.com... > > > > > Dirk Herrmann wrote: > > > > FpB'Image(FpB'(-1.5)) evaluates to -1.2 > > > FpB'Image(FpB(FpA'(-1.5))) evaluates to -1.2 > > > FpB'Image(MakeBFromA(FpA'(-1.5))) evaluates to -1.6 > > The answer is curious (and I'm not sure if it's what the language > > designers intended). =A04.9(38) says, ... > ... > > If FpB'Machine_Rounds is FALSE, though, the situation is interesting. > > 4.9(38) requires that static expressions get *truncated* toward zero, > > as I read it. =A0But there's no similar requirement for expressions > > computed at runtime. > > Having played with this on GNATPro 6.1.2 (to PC target) it does report > FpB'Machine_Rounds as false. =A0It also rounds values like -1.59999 down = to > -1.2 (which is a logical consequence). =A0Technically this is still withi= n the > error bounds declared for FpB (delta 0.4) so it is not "wrong" within the > rules of the language definition. =A0But it is very counter-intuitive and= is > the sort of thing I find frustrating. > > I also tested the problem on GreenHills AdaMULTI (4.2.3 to PowerPC target= ); > this gave FpB'Machine_Rounds as true and gave the more intuitive results. > > =A0 =A0-1.5 =A0 =A0 =A0 =A0 -> -1.6 > =A0 =A0-1.40001 -> -1.6 > =A0 =A0-1.4 =A0 =A0 =A0 =A0 -> -1.2 > > So although there does look to be a language "gotcha" here, it depends up= on > the compiler's choice of 'Machine_Rounds. > > -- > Stuart This is all very weird. Can I point you to my earlier post at http://groups.google.com/group/comp.lang.ada/msg/f79a71b9abe7e287 which (unless I'm deluded) shows GNAT rounding away from zero for dynamic values even though 'Machine_Rounds is False!! (and I get the same results on Ubuntu 8.04 with GNAT GPL 2008.