English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Strange behaviour of string_of_float
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-06-22 (19:58)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Strange behaviour of string_of_float
On Sun, Jun 22, 2008 at 06:56:22PM +0200, Paolo Donadeo wrote:
> string_of_float is not the inverse of float_of_string, at least in
> this example.

Yes, you wouldn't expect it to be, because the string is an
approximate base 10 representation of the float (which is itself only
an approximate base 2 representation of the transcendental number pi).
You might want to read a presentation called "What every computer
programmer should know about floating point arithmetic".  There's a
PDF version here:



Richard Jones
Red Hat