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!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!news.netcologne.de!ramfeed1.netcologne.de!newsfeed.arcor.de!newsspool2.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> Date: Sun, 22 Aug 2010 20:16:15 +0200 Message-ID: NNTP-Posting-Date: 22 Aug 2010 20:16:13 CEST NNTP-Posting-Host: 71b40fbd.newsspool3.arcor-online.net X-Trace: DXC=V8AXEJ6oLXOk:C4l9A;OcOMcF=Q^Z^V3H4Fo<]lROoRA8kFSg_hJ48<=H X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:13620 Date: 2010-08-22T20:16:13+02:00 List-Id: On Sun, 22 Aug 2010 10:15:24 -0700 (PDT), Ada novice wrote: > I didn't quite get this part. In my previous example with say a = 2.33 > and b = 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 = 8.0385 and then approximating this result to the nearest > model number? No, the result is 8.0385 (assuming 32-bit machine numbers). Try this: with Ada.Text_IO; use Ada.Text_IO; procedure Test_Float is type My_Float is digits 3; X : My_Float := 2.33; Y : My_Float := 3.45; begin Put_Line ("Model view:" & My_Float'Image (X*Y)); Put_Line ("The reality:" & Float'Image (Float (X*Y))); end Test_Float; It should print: Model view: 8.04E+00 The reality: 8.03850E+00 When you print the number using My_Float'Image that rounds the machine number to the nearest model number. In computations and conversions machine numbers are left untouched. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de