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-Thread: 103376,548c38bb2d3e1bb6 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!s9g2000yqd.googlegroups.com!not-for-mail From: Ada novice Newsgroups: comp.lang.ada Subject: Re: understanding floating point types Date: Sun, 22 Aug 2010 10:15:24 -0700 (PDT) Organization: http://groups.google.com Message-ID: <37d8fbc1-fdaf-4ca9-9393-6163f2e3fa2e@s9g2000yqd.googlegroups.com> References: <74406fc1-f64b-4a3e-9dd6-301f1ed467ab@w30g2000yqw.googlegroups.com> <7b0ca24f-4a5e-43a9-9f71-e4adffb98694@q1g2000yqg.googlegroups.com> NNTP-Posting-Host: 193.11.22.91 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1282497324 16669 127.0.0.1 (22 Aug 2010 17:15:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 22 Aug 2010 17:15:24 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s9g2000yqd.googlegroups.com; posting-host=193.11.22.91; posting-account=Rr9I-QoAAACS-nOzpA-mGxtAlZ46Nb6I User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:13615 Date: 2010-08-22T10:15:24-07:00 List-Id: On Aug 22, 3:57=A0pm, "Dmitry A. Kazakov" wrote: > > =A0 =A0My_Float'Machine_Mantissa =3D 53 (64-bit IEEE 754 is used to model= it) > =A0 =A0My_Float'Mantissa =3D 25 > Yes. This is good. For Long_Float, Long_Float'Mantissa is 51. > > I would expect that all computations performed in machine numbers, not > because it is mandated, I believe it is not, but because it is simpler to > implement. At least with GNAT it is so. Try this: > > =A0 =A0type My_Float is digits 2; > =A0 =A0X : My_Float :=3D 1.0 / 3.0; > =A0 =A0... > =A0 =A0Put_Line (Float'Image (Float (X))); > > The output will be: 3.33333E-01 > > If you can pick any number from the interval [0.33, 0.34[ to represent 1/= 3 > in with 2 decimal digits. Why not 0.333333? > I didn't quite get this part. In my previous example with say a =3D 2.33 and b =3D 3.45. Does Multiplication of a with b mean converting each of a and b in model number first and then do the multiplication and afterwards approximating the result to the nearest model number? Or the multiplication will just be performed with the two numbers as 2.33 X 3.45 =3D 8.0385 and then approximating this result to the nearest model number? Thanks. YC