From: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
To: Kenichi Asai <asai@is.ocha.ac.jp>,
Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] string_of_float (0.1 +. 0.2)
Date: Wed, 15 Jun 2022 16:25:53 +0200 [thread overview]
Message-ID: <etPan.62a9ebf6.462d9d5f.12f3c@erratique.ch> (raw)
In-Reply-To: <CAPFanBFf-ksPwj48=TZX+GzTOe5cM=cL_i_RnK+gjiRWNmyFtA@mail.gmail.com>
On 15 June 2022 at 16:07:58, Gabriel Scherer (gabriel.scherer@gmail.com) wrote:
> Kenichi, I don´t understand what your own constraints, but
> in general I have the impression that "float" is better than "string"
> to represent double values used for computation.
If there a reason not to do what Gabriel suggests you can serialize a bit-by-bit accurate representation of floats[^1] by using `Format.sprintf "%h"`. This format can be input again with float_of_string.
Daniel
[^1]: There may be edge cases with nans since those will all be serialized to the string "nan" and input back as OCaml's Float.nan value.
next prev parent reply other threads:[~2022-06-15 14:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 1:59 Kenichi Asai
2022-06-15 6:22 ` Andreas Rossberg
2022-06-15 7:00 ` François Pottier
2022-06-15 14:07 ` Gabriel Scherer
2022-06-15 14:25 ` Daniel Bünzli [this message]
2022-06-16 1:45 ` Kenichi Asai
2022-06-16 6:24 ` Oleg
2022-06-16 9:01 ` Andreas Rossberg
2022-06-16 9:14 ` [Caml-list] unsubscribe Jean-Denis EIDEN JEAN-DENIS
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=etPan.62a9ebf6.462d9d5f.12f3c@erratique.ch \
--to=daniel.buenzli@erratique.ch \
--cc=asai@is.ocha.ac.jp \
--cc=caml-list@inria.fr \
--cc=gabriel.scherer@gmail.com \
/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