Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] float type with better precision than the default
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] float type with better precision than the default
On Fri, 5 Dec 2003 romildo@uber.com.br wrote:

> Hello.
> 
> A friend of mine needs a type for float numbers
> with better precision than the precision offered
> in the default float type. He also needs efficiency
> in his application.

Ocaml floats are spec'd to be IEEE 754 double precision.  This gives you 
enough accuracy to measure the distance from here to the moon in microns-
15 decimal digits.  30 decimal digits is enough accuracy to measure the 
distance between here and the Andromeda Galaxy in microns.  Why does he 
need such a ridiculous amount of precision?

But the short answer is he is basically SOL.  The x86 has an 80-bit FP
format (~18 digits of accuracy), and the PA-RISC can do 128-bit FP at a
signifigant performance hit (1/2 the speed of double precision, IIRC).  
But no one else I know of does more than double precision in hardware.  
Which means software emulation, and really slow performance.  You might 
gain a little by hardcoding the precision (GMP implements arbitrary 
precision floats), but not enough to make up the difference.

Especially after, as I predict, you discover that 30 bits of precision 
isn't enough either.

Instead, I'd recommend your friend take his algorithm over some day to 
whatever nearby college you have and find whomever teaches the Numerical 
Analysis class, and talk the algorithm over with that professor.  I'd bet 
dollars to donuts that his algorithm is numerically unstable, and once 
he's done taking that professor's advice, double precision will be more 
than enough precision.

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners