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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,20419503734d9ed8 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Float & precision Date: 1999/10/17 Message-ID: <7udvu1$th$1@ash.prod.itd.earthlink.net>#1/1 X-Deja-AN: 537341495 Content-Transfer-Encoding: 7bit References: <3807ba57.277208181@news.dsuper.net> <38088ba5.330797551@news.dsuper.net> <7uc86m$cob$1@holly.prod.itd.earthlink.net> <380b47e6.444543814@news.dsuper.net> X-Posted-Path-Was: not-for-mail Content-Type: text/plain; charset="iso-8859-1" X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-ELN-Date: 18 Oct 1999 02:16:33 GMT X-ELN-Insert-Date: Sun Oct 17 19:25:03 1999 Organization: Ada95 Press, Inc. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-10-17T00:00:00+00:00 List-Id: wrote in message news:380b47e6.444543814@news.dsuper.net... > On Sun, 17 Oct 1999 05:23:55 -0500, "David C. Hoos, Sr." > wrote: > > > Of course this will not work as simply as that since my intermediate > result could be of any order of magnitude with positive or negative > exponent. So I may have to multiply it by 10^x or divide it by 10^x, > and then I'd have to figure out what x should be based on the > intermediate result, so as to bring the value within the interger or > long integer's range. > > Will a typecast into a discrete (integer) value not eliminate those > non significant digits, thus rounding to a specific position ? > No. Not unless your integer has more bits than the mantissa of the floating point type, and then, only if a scale factor is chosen such that there is no overflow. By the way, "typecast" is not an Ada term. You probably mean "type conversion" or "type convert." > I'm just sort of playing, going beyond the scope of my school work, > trying to think of a relatively simple way to do it. After all my > pocket calculator does it without problems. It's an old cheap Casio > model. I don't know if operates with 32 or 64 bits or maybe something > else. The reason your pocket calculator _appears_ to do it without problems, is that it does the calculations internally with a couple more digits than it displays. You can get the same effect in Ada with the gnat compiler by doing your computations in long_long_float, then converting to long_float for display.