Version française
Home     About     Download     Resources     Contact us    
Browse thread
float printing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe Raffalli <christophe.raffalli@u...>
Subject: float printing

I have a small problem to read and write float in a file. I use the
format library and there is no way to write/read a float in hexadecimal
to be sure you read exactly the same float back from the file (a n bits
mantisse float may need n decimals to have an exact representation.
Just compute 1/2^n and count decimals).

The only way is to convert the float to string via Printf and then print
the string with Format.print_string.

Don't you think Pervasives and format should have a write/print_hexfloat
and Pervasives should have an input_hexfloat function ?

--
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------