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,start X-Google-Attributes: gid103376,public From: fluffy_pop@dsuper.net Subject: Re: Float & precision Date: 1999/10/17 Message-ID: <380b47e6.444543814@news.dsuper.net>#1/1 X-Deja-AN: 537288824 Content-Transfer-Encoding: 7bit References: <3807ba57.277208181@news.dsuper.net> <38088ba5.330797551@news.dsuper.net> <7uc86m$cob$1@holly.prod.itd.earthlink.net> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@idirect.com X-Trace: quark.idirect.com 940199295 207.139.170.49 (Sun, 17 Oct 1999 18:28:15 EDT) Organization: via Internet Direct - http://www.mydirect.com/ MIME-Version: 1.0 NNTP-Posting-Date: Sun, 17 Oct 1999 18:28:15 EDT Newsgroups: comp.lang.ada Date: 1999-10-17T00:00:00+00:00 List-Id: On Sun, 17 Oct 1999 05:23:55 -0500, "David C. Hoos, Sr." wrote: Thank you very much for spending the time to help. I was vaguely aware of what you are talking about. >There is a way to manipulate the bits of the mantissa apart from the >exponent, but this will not solve the problem. > >The problem is that a decimal value is in general not exactly >representable in binary in finite length. > ... >Thus, the nearest two values to 1.3, expressed in IEEE 32-bit floating >point (gnat Float on a PC), displayed here in decimal to 18 significant >digits of precision are: > 1.29999995231628418E+00 > 1.30000090599060059E+00 Why could I not adjust my result after each sigle operation, intermediate steps. Someone suggested to multiply the intermediate result by a certain power of ten (0.0001 for the particular example I had given him) and to typecast it into an integer (long integer would be much better), and then to go back (do the two operations in reverse). 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 ? 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. Thanks again. Marc Galipeau -- What I really am is "fluffy", no "_dong", no "_puff", no "_woo", no nothing, just plain fluffy.