[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: WJL@zermatt.lcs.mit.edu*Subject*: doubling your bits*From*: "David L. Andre" <DLA@diamond.s4cc.symbolics.com>*Date*: Tue, 24 Nov 87 16:26 EST*Cc*: SLUG@zermatt.lcs.mit.edu*In-reply-to*: <871124141625.1.WJL@GALEN.LCS.MIT.EDU>*Resent-date*: Tue 24 Nov 87 18:54:54-CST*Resent-from*: CMP.SLUG@r20.utexas.edu*Resent-message-id*: <12353283850.48.CMP.SLUG@R20.UTEXAS.EDU>*Resent-to*: SLUG:;

Date: Tue, 24 Nov 87 14:16 EST From: Bill Long <WJL@ZERMATT.LCS.MIT.EDU> Having just noticed that: (coerce .1 'double-float) = 0.10000000149011612d0 This is right, of course. We get so many complaints about this from people who are not familiar with floating point numbers, that in 7.2 we have added extensions so that you can see the precise value of the floating point number you are using. For example, (write .1 :exact-float-value t) ==> 0.100000001490116119384765625 which is the closest IEEE floating point number to 1/10. When you asked for the closest double-precision number to that, you got it. If you still don't understand this, you should consult a textbook on floating point. I was wondering... 1) How much slower would coerce be if it added decimal zeros? eg., (coerce .1 'double-float) -> 0.1d0 It would be wrong. 2) How do other Commonlisp implementations handle this? It depends on what floating-point format they support. Any implementation of IEEE floating point in any language will do this. 3) If I really want the additional digits to be zeros, is there any faster way than something like: (coerce (/ (round .1 .00000001) 100000000) 'double-float) How about (coerce 1/10 'double-float)? Happy Thanksgiving! -Bill Long

**Follow-Ups**:**doubling your bits***From:*Bill Long <WJL@zermatt.lcs.mit.edu>

**References**:**doubling your bits***From:*Bill Long <WJL@zermatt.lcs.mit.edu>

- Prev by Date:
**Font Conversion** - Next by Date:
**doubling your bits** - Previous by thread:
**doubling your bits** - Next by thread:
**doubling your bits** - Index(es):