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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,388fc53f584bd695 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!feeder.erje.net!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Fixed point constants issue Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Mon, 13 Sep 2010 20:04:32 +0200 Message-ID: <1f0l0baynq1x7$.phl9cqpwcr37.dlg@40tude.net> NNTP-Posting-Date: 13 Sep 2010 20:04:31 CEST NNTP-Posting-Host: 9ad51869.newsspool1.arcor-online.net X-Trace: DXC=YnHH`9h6B5j9kIfcjg:0fdic==]BZ:afn4Fo<]lROoRa<`=YMgDjhgbZFm4oJHSm]j[6LHn;2LCVn[kk X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:14048 Date: 2010-09-13T20:04:31+02:00 List-Id: On Mon, 13 Sep 2010 19:27:30 +0200, Vinzent Hoefler wrote: > Is this a GNAT bug or am I just stupid? > > Suppose we have a fixed point type (with a rather large delta): > > -- 8< -- > with Ada.Text_IO; use Ada.Text_IO; > > procedure Fixed_Point > is > FEET_PER_METER : constant := 0.3048; > HEIGHT : constant := 10; -- Feet > > type Altitude is delta (2.0**15 / 50_000.0) range 0.0 .. 50_000.0; [...] > Can anyone shed some light on this? This has driven us crazy for weeks now. > > [1] Of course, "Altitude'(HEIGHT * FEET_PER_METER)" yields "0.0" again. > At least this is consistent with my understanding so far. Hmm, what did you expect? 0.3048 (FEET_PER_METER) is 0 when Altitude. That is because 2.0**15/50_000.0=0.65536 > 0.3048. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de