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,FROM_NUMERIC_TLD autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,6fabd104d18f3943 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!novia!news-xxxfer.readnews.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail From: "Stuart" Newsgroups: comp.lang.ada References: Subject: Re: conversions between fixed-point types Date: Fri, 25 Sep 2009 09:47:24 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3598 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 Message-ID: <4abc8389$1_1@glkas0286.greenlnk.net> X-Original-NNTP-Posting-Host: glkas0286.greenlnk.net NNTP-Posting-Host: da5bbf4a.gradwell.net X-Trace: DXC=f?:>O>?4Z=OFIOlQA0Hh@J@lWf8?fSK:AjS@R6]oDiIO0 "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). 4.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. But 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. It also rounds values like -1.59999 down to -1.2 (which is a logical consequence). Technically this is still within the error bounds declared for FpB (delta 0.4) so it is not "wrong" within the rules of the language definition. But 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. -1.5 -> -1.6 -1.40001 -> -1.6 -1.4 -> -1.2 So although there does look to be a language "gotcha" here, it depends upon the compiler's choice of 'Machine_Rounds. -- Stuart