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

*To*: "Stewart G. Tattersall" <sgt@cs.unr.edu>*Subject*: Clisp940204 add problem*From*: hoehle@inf-wiss.uni-konstanz.de (Joerg-Cyril Hoehle)*Date*: Mon, 20 Feb 95 19:24:13 +0100*Cc*: clisp-list@[129.13.115.2]*In-reply-to*: <Pine.ULT.3.91.950218122121.2661A-100000@hunter>*References*: <Pine.ULT.3.91.950218122121.2661A-100000@hunter>

Stewart G. Tattersall writes: > > (+ 8.625 5.44) > 14.065001 > > > (+ 8.625 13.44) > 22.064999 > > > (+ 8.625 113.44) > 122.065 > > > (+ .625 .44) > 1.065 > What is causing this error is a mystery to me. Maybe it's not an error but a symptom of the limited mantissa of the floating point format. Most decimal numbers have no exact log2 representation and converting between the two representations causes the output you see. 0.999999999999999999999.... and 1.0 are the same numbers. With a limited mantissa you only get an approximation of the first. 5.44 is represented internally as 101.011100001010001111011 where it would really be 101.01110000101000111101011100001010001111010111000010100011110101110... ^ > I would like to see a bug fix. CLISP gives you a choice of four floating point formats. Try (setq *READ-DEFAULT-FLOAT-FORMAT* 'short-float) with one of SHORT-FLOAT, SINGLE-FLOAT (the default), DOUBLE-FLOAT and LONG-FLOAT. It might give you want you are looking for. It must not. You can choose the minimal number of digits to compute with in the long-float format. The default is 64. Otherwise you might give a try to rational arithmetic: > (+ 8625/1000 544/100) 2813/200 > (float *) 14.065 (Have a look at *DEFAULT-FLOAT-FORMAT* for this last conversion). > This problem is making me look bad using lisp as my environment of > choice. You could get the same with any language, with a pocket calculator or a Cray. > > (LISP-IMPLEMENTATION-VERSION) > "January 1994" > > My system is an A3000. You'll get exactly the same results with the January 1995 Sun4m CLISP version. Regards, Joerg Hoehle. hoehle@inf-wiss.uni-konstanz.de

- Prev by Date:
**Re: Linux and the latest version** - Next by Date:
**Vectors and fill-pointers** - Previous by thread:
**Re: Linux and the latest version** - Next by thread:
**Vectors and fill-pointers** - Index(es):