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,548c38bb2d3e1bb6 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!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.k-dsl.de!news.doubleslash.org!open-news-network.org!news.teledata-fn.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: understanding floating point types 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: <74406fc1-f64b-4a3e-9dd6-301f1ed467ab@w30g2000yqw.googlegroups.com> <7b0ca24f-4a5e-43a9-9f71-e4adffb98694@q1g2000yqg.googlegroups.com> <37d8fbc1-fdaf-4ca9-9393-6163f2e3fa2e@s9g2000yqd.googlegroups.com> <2d2a622b-6c4a-45b7-9e3c-a565d5dbc9e3@p3g2000yqp.googlegroups.com> Date: Sun, 22 Aug 2010 21:34:41 +0200 Message-ID: <7mcl3j29wtw1.xle9n3lvga8c.dlg@40tude.net> NNTP-Posting-Date: 22 Aug 2010 21:34:39 CEST NNTP-Posting-Host: 01e7436c.newsspool3.arcor-online.net X-Trace: DXC=]aAZQ^gCg^b<6cDJZfMd_cMcF=Q^Z^V3h4Fo<]lROoRa8kF1@A\TYiM3k[6LHn;2LCVn[ On Sun, 22 Aug 2010 12:05:33 -0700 (PDT), Ada novice wrote: > 1. You used: type My_Float is digits 3; I tend to confuse the fact > that digits 3 means 3 digits of precision after the decimal point? So > when I consider 2.33 or 3.45, then both numbers are with digits 2 in > my mind. Or does digits 3 mean 3 significant digits which will include > the leading 2 in 2.33 and the leading 3 in 3.45 as well? Yes, it is relative, in the case of floating-point numbers. Ada has another model of real numbers, the fixed point numbers, they have an absolute precision. > 2. In your example, you have: > > Model view: 8.04E+00 > The reality: 8.03850E+00 > > If I understand correctly, model view represents the number that is > exactly representable by the computer. Yes, the model number is your requirement. The machine number is an implementation that fulfills your requirement. > In our case here, we can get > the reality number since Float has higher precision digits than > My_Float. However if My_float used the same precision digits as Float > (i.e. 6) then this would also represent the number that could be > represented by the computer. If both a and b had a hypothetical 30 > digits of precision, then neither Float (6 digits) nor Long_Float (15 > digits), nor Long_Long_Float (18 digits) would give the right value > that would represent the model number of the multiplication result > a*b. Neither they would a or b. 30 digits precision require 101 bits of machine mantissa. > I mentioned the word hypothetical, as we would not able to use a > number with 30 digits of precision anyway on a computer. But my point > was to say that Model view doesn't have to have less precision digits > as the reality number. The machine number precision must be equal or greater than the model one. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de