[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Ken Rose <kenrose@t...> |
| Subject: | Re: [Caml-list] float printing |
Christophe Raffalli wrote: > > 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 ? Maybe Int64.bits_of_float and Int64.float_of_bits will do what you need. - ken