English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    
Browse thread
RE: Re: [Caml-list] string_of_float less accurate than sprintf "%f" ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: artboreb@n...
Subject: RE: Re: [Caml-list] string_of_float less accurate than sprintf "%f" ?
John Max Skaller <skaller@ozemail.com.au> wrote:

Hi all,

>Francois Thomasset wrote:
>
>>>Beck01, Wolfgang wrote:
>>>
>>>There's another problem too:
>>>
>>># string_of_float 42.0;;
>>>- : string = "42"
>>>
>>>The result isn't an ocaml float literal.
>>>
>>Is it not?
>># float_of_string (string_of_float 42.0);;
>>- : float = 42
>>So if you know that there is a float in the string, it is a float isn't it?
>>
>It isn't a floating point literal, in ocaml, C, or any other language.
>Floating point literals always have either a decimal indicator
>or an exponent. It should return "42.0", in my opinion:
>"42" is an integer.

In fact "42" is only a string. Strictly it cannot be infered nothing else
without a radix indicator and an explicit type of internal representation
"42.0" should be interpreted as a decimal floating point value
"42.00" another decimal floating point value with better accuracy 
"42o" would be interpreted as an octal value, integer, character or other?
"42h" same, an hexadecimal value 
So the meaning of "42" only would be infered within the context on where
"42" occurs. if "42" appear on the cash report of my credit card most
probably it means a decimal currency value (or perhaps a code?)
We do this all the time (infering), it is part of our culture, but 
sometimes the context imposes full strict information of "42" such as
"42.0 +/- 1e-9" = "42.00000000" or "0x0042" or "+0x00000042" or "US$42.0"
or "42 KSLOC" .......... or wathever
My oppinion is that this stuff has nothing to do with Caml it is only
related to code the correct printf in the correct place.

Regards

-- 
Arturo Borquez



__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

-------------------
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