[erlang-questions] pre-EEP: accurate float printing (replacement for io_lib_format:fwrite_g/1)
Wed Dec 12 00:58:07 CET 2007
On 12/11/07, Robert Virding <rvirding@REDACTED> wrote:
> On 11 Dec 2007 10:10:48 +0100, Bjorn Gustavsson <bjorn@REDACTED>
> > "Bob Ippolito" <bob@REDACTED> writes:
> > > ~g with no precision specification (io_lib_format:fwrite_g/1) is a
> > > perfect target and it hits every use the shell has, ~f and ~e I don't
> > > care about. Having yet another float format would be completely stupid
> > > and confusing to anyone that doesn't know the back story for why
> > > supposed backward compatibility required the need for another format.
> > > Other languages have undergone this type of change with no ill effects
> > > that I've heard of (e.g. TCL did this in 2003 ).
> > I agree. If there are no compatibility problems *in practice*, we
> > should simply make the change.
> I agree, we should change if no real problems are found. What I don't
> understand is why just have it for ~g with no precision and not for all
> cases of ~g, ~f and ~e? They are really just shifting the decimal dot and
> fixing the exponent.
The current implementation does what ~g does: if there's going to be a
lot of zeros, then it switches to ~e, otherwise it's ~f. We only
really care about ~g (if it's implemented with this algorithm, with no
explicit precision specification) because our use cases are the shell
and accurate and compact text serialization (JSON specifically).
More information about the erlang-questions