From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!skynet.be!skynet.be!ossa.telenet-ops.be!nmaster.kpnqwest.net!nreader3.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: Lisp Programmers in X Months References: <3CB0B7C6.50701@yahoo.com> <874rin9n10.fsf@nkapi.internal> <3CB1D61C.4070104@yahoo.com> <=vGxPITJODE6F3WVaY+470h+hO8J@4ax.com> Mail-Copies-To: never From: Erik Naggum Message-ID: <3227810034793834@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 75 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 14 Apr 2002 21:53:58 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader3.kpnqwest.net 1018821238 193.71.199.50 (Sun, 14 Apr 2002 23:53:58 MET DST) NNTP-Posting-Date: Sun, 14 Apr 2002 23:53:58 MET DST Xref: archiver1.google.com comp.lang.lisp:31694 * Christopher Browne | 1.52 is 10^1 * 1369094242697216 / 2^53 | 1.75 is 10^1 * 1576259842736128 / 2^53 Huh? 1.75 is 7/4, and can be represented exactly using any base-2 floating point. Your value is 0.175, which cannot. But why did you divide by 10 first? This is a really, really bad way of converting floating-point numbers to and from internal form. I have no idea where this 10^1 thing comes from, but it is usually the other way around, you have 175/1000, not 0.175*10. What I get is this (with *read-default-float-format* permanently set to double-float) (integer-decode-float 1.52) => 6845471433603154 => -52 => 1 (integer-decode-float 1.75) => 7881299347898368 => -52 => 1 Adding these together, I get 14726770781501522 / 2^52 which is fortunately identical to 7363385390750761 / 2^51. | Adding them together gives you | | 10^1 * 2945354085433344 / 2^53 | | This does happen to coincide with the FP representation of 3.27, but | _none_ of the values were exact Well, at least one was. | The exact FP value of the result, 3.27, is | (* 10 2945354085433344 (/ 1 (expt 2 53))) | 54861495/16777216 (integer-decode-float 3.27) => 7363385390750761 => -51 => 1 | Comparing that to the exact result: | (- 54861495/16777216 327/100) | -33/419430400 | | The result is absolutely NOT "exact"; it is off by -33/419430400. This is a pretty odd way to calculate things. (rational 3.27) => 7363385390750761/2251799813685248 (- * 327/100) => 1/56294995342131200 However, we also have (- (rational 1.52) 152/100) => 1/56294995342131200 I have no idea where you learned floating-point representation, but you have just introduced a computational error by working with more inexact values than you could have, and you have not reported your inaccuracies for the operands, only the result. I wonder why you did this. Nobody does normalization in the decimal realm _before_ converting to binary. /// -- In a fight against something, the fight has value, victory has none. In a fight for something, the fight is a loss, victory merely relief. Post with compassion: http://home.chello.no/~xyzzy/kitten.jpg