[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sam Steingold <email@example.com> writes:
> 1. I do set *read-default-float-format* = double-float. The numbers
> are still read as singles.
Just a guess why this happens: Maybe you have floating point constants
without precision suffix in your program. When you load a compiled file
(setq *read-default-float-format* 'double-float)
(defvar x 1.0)
then x will be a single-float nevertheless. To avoid this, wrap the
setq form inside (eval-when (compile load eval) ....).
> To use your impnotes example: "(- (+ 1.7 pi) pi) should not return
> 1.700000726342836417234L0," This 1.700000whatever is still 1.7, for
> purposes of practical computations.
But when a program prints out a 21-digit number, how could you (as a user)
guess that this number has only 7 correct places?
> But when I am getting *negative*
> standard deviations, this is not correct in any possible sense!!!!
If you are getting negative radicands when computing standard deviations,
need to take a formula with better numerical stability [i.e. replace
n*sum(i,x_i^2) - sum(i,x_i)^2 by n*sum(i,(x_i-sum(j,x_j)/n)^2) ],
need to work with larger precision. In this case, if somehow a
single-float enters the computations, you would still see negative
radicands and wonder where they come from. With CLISP you'll see
a single-float negative radicand, and that will point you to the
> You think that a float is always imprecise. You are *wrong*. 123456.7
> is *precise*, and I should not have to use ratios to tell clisp that!
If you want 123456.7 to be precise, you either need to use ratios (or,
equivalently, a fixed-point representation), or a floating-point
representation with base 10 (e.g. GNU bc uses this). CLISP chose, for
efficiency and for compliance with the IEEE standards, a floating-point
representation with base 2.
> Anyway, can you name another computer system where
Yes. PARI 2.0.alpha for example:
GP/PARI CALCULATOR Version 2.0.alpha
(i586 running linux 32-bit version)
(readline disabled, extended help available)
Copyright 1989-1997 by
C. Batut, K. Belabas, D. Bernardi, H. Cohen and M. Olivier.
Type ? for help.
realprecision = 28 significant digits
seriesprecision = 16 significant terms
format = g0.28
parisize = 4000000, primelimit = 500000, buffersize = 30000
? x = sqrt(2)
%1 = 1.414213562373095048801688724
%2 = 28
realprecision = 50 significant digits
%3 = 28
? y = sqrt(3)
%4 = 1.7320508075688772935274463415058723669428052538103
%5 = 57
%6 = 28
%7 = 28
%8 = 28