[erlang-questions] pre-EEP: accurate float printing (replacement for io_lib_format:fwrite_g/1)

Raimo Niskanen raimo+erlang-questions@REDACTED
Tue Dec 11 09:09:06 CET 2007

I suggest you make the EEP for a new io_lib floating point print
format. The problem here is to find a good letter since ~e, ~f
and ~g are already used. Perhaps it can be done through some
unused precision specifier... Changing an existing feature can always
cause all kinds of unexpected problems. Then suggest that the shell
should use the new format.

These sound like nice backwards compatible changes that have a
good chance of being accepted.

On Mon, Dec 10, 2007 at 01:40:26PM -0800, Bob Ippolito wrote:
> If we submit a patch to io_lib_format:fwrite_g/1 to use an accurate
> floating point decimal representation, would it be accepted? If not,
> is there a less intrusive way that we could override this?
> I find it VERY annoying to have the shell print "~.5g", since that
> often doesn't have enough precision to see what I need to see in the
> floats we work with. I also generally prefer to see "0.1" instead of
> "0.10000".
> We have a suitable implementation here, which is the same algorithm
> that several other programming languages use and there's a paper that
> proves its correctness:
> http://mochiweb.googlecode.com/svn/trunk/src/mochinum.erl
> It could probably be made a little faster if necessary by using a
> pre-calculated set of results for int_pow that covers the range that
> the algorithm needs, e.g.:
> int_pow(10, 0) -> 1;
> int_pow(10, 1) -> 10;
> ...
> int_pow(10, 324) -> ...
> -bob
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions


/ Raimo Niskanen, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list