Re: float_to_list(X)

Themba Jonga <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAPVvff264NnWmJV2D8zos_A3=E9rJ2VLtgTeVnH-EPuOQheVDw@mail.gmail.com>
Hi, again.

Following a response I got from Dmitry Klionsky, perhaps it makes sense for
*float_to_list(N)* to be made into a wrapper for
*lists:flatten(io_lib:format("~p",[N]))?*

Eshell V11.1  (abort with ^G)
1> N = 4.4445.
4.4445
2> lists:flatten(io_lib:format("~p",[N])).
"4.4445"
3> P = 5.4443.
5.4443
4> lists:flatten(io_lib:format("~p",[P])).
"5.4443"
5> Q = 1.2345678.
1.2345678
6> lists:flatten(io_lib:format("~p",[Q])).
"1.2345678"
7> float_to_list(Q).
"1.23456779999999999298e+00"
8>

Regards

*Themba Jonga*



<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#m_1222824999368714802_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Wed, 5 May 2021 at 18:38, Scott Ribe <[email protected]> wrote:

> > On May 5, 2021, at 10:20 AM, [email protected] wrote:
> >
> > In short, no.
>
> Although many (most, actually nearly all) real numbers cannot be
> represented precisely as a float, any float can be round-tripped to text
> and back exactly. This is part of the IEEE floating point standard,
> actually. (And it's not easy...)
>
>
>
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.