Re: Floating point issue in sbcl 1.0.10?



On Oct 30, 8:07 pm, steven.w.lev...@xxxxxxxxx wrote:
As a lisp newbie, I'm sorry if this one is obvious. However, I'm a
bit puzzled by the
following executed from the prompt:

* (- 1234.56 4.57)

1229.9901

I tried this with several installations of this (ubuntu, compiled from
src, and
precompiled binary). Any ideas?

If you're wondering about the lack of perfection, other posts have
addressed that. If you're wondering about the lack of precision, the
following may provide some insight:

CLisp 2.41

[1]> (- 1234.56 4.57)
1229.9901
[2]> (- 1234.56d0 4.57d0)
1229.99d0
[3]> (- 1234.56l0 4.57l0)
1229.9900000000000001L0
[4]> (- 1234.56f0 4.57f0)
1229.9901

I just looked that up on p. 118 of Practical Common Lisp. Are there
other ways to indicate to the compiler which precision one wants?

Brian Adkins

.



Relevant Pages

  • Re: Conformance
    ... They give a precision of approx 30 decimal digits ... This only increases the precision, not the range, and there are tricky ... Does your compiler pad qfloats to 512 bits or do your refer to ... qfloat s = 3.1415965358979323846264338327950288419Q; ...
    (comp.std.c)
  • Re: Numerical accuracy of C++ and Fortran programs on 32 bit machines
    ... ....snip prior discussion and example where average error of extension of ... > double precision constants 1.2D0 etc. (and at the moment this seems to ... > compiler should issue a warning, but in my opinion it should not be so ... The /fpconstant option requests that a single-precision constant ...
    (comp.programming)
  • Re: Chipmunk Basic arrays (Attn: Ron Nicholson)
    ... it is a PITA for the programmer because it ... specific precision, then you need to be able to specify that to the compiler. ... when the compiler forced him to choose a data type. ...
    (comp.lang.basic.misc)
  • Re: Chipmunk Basic arrays (Attn: Ron Nicholson)
    ... get into hardware issues (and integer size, digits of precision, ... the creators of the compiler. ... it is a PITA for the programmer because ... having to choose a data type for _every_ variable ...
    (comp.lang.basic.misc)
  • Re: What is wrong with this code?
    ... Uh, yeah, for me on this compiler, just a warning, I think. ... ridiculous contortions to avoid using a pointer to an ARRAY. ... The use of a global struct is another unnecessary design flaw. ... the extra precision. ...
    (comp.lang.c)