caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* RE: Re: [Caml-list] string_of_float less accurate than sprintf "%f" ?
@ 2002-05-06  5:10 Arturo Borquez
  0 siblings, 0 replies; only message in thread
From: Arturo Borquez @ 2002-05-06  5:10 UTC (permalink / raw)
  To: John Max Skaller; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-05-06  5:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-06  5:10 Re: [Caml-list] string_of_float less accurate than sprintf "%f" ? Arturo Borquez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).