From: artboreb@netscape.net (Arturo Borquez)
To: skaller@ozemail.com.au (John Max Skaller)
Cc: caml-list@inria.fr
Subject: RE: Re: [Caml-list] string_of_float less accurate than sprintf "%f" ?
Date: Mon, 06 May 2002 01:10:29 -0400 [thread overview]
Message-ID: <1D8D271E.572478E7.00958B05@netscape.net> (raw)
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
reply other threads:[~2002-05-06 5:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1D8D271E.572478E7.00958B05@netscape.net \
--to=artboreb@netscape.net \
--cc=caml-list@inria.fr \
--cc=skaller@ozemail.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox