| Author |
Message |
|
| partizan |
Posted: Sun Jan 10, 2010 5:12 pm |
|
|
|
Joined: 07 Sep 2009
Posts: 2
|
Release: R13B03
Steps to reproduce:
1) erlang:list_to_float("42")
Expected result:
42.0 (float)
Actual result:
error:badarg
--
With best regards,
Alexander Borovsky
________________________________________________________________
erlang-bugs mailing list. See http://www.erlang.org/faq.html
erlang-bugs (at) erlang.org
Post received from mailinglist |
|
|
| Back to top |
|
| uwiger |
Posted: Sun Jan 10, 2010 5:58 pm |
|
|
|
User
Joined: 03 Jul 2006
Posts: 604
Location: Sweden
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alexander Borovsky wrote:
> Release: R13B03
>
> Steps to reproduce:
> 1) erlang:list_to_float("42")
>
> Expected result:
> 42.0 (float)
>
> Actual result:
> error:badarg
Arguably, this is in line with the documented behaviour:
"list_to_float(String) -> float()
Types:
String = string()
Returns the float whose text representation is String.
> list_to_float("2.2017764e+0").
2.2017764
Failure: badarg if String contains a bad representation of a float."
There is no float that has the text representation "42".
Eshell V5.7.2 (abort with ^G)
1> is_float(42).
false
BR,
Ulf W
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAktKFVIACgkQtqqFieqzed2K+wCeN/rCVoLwk8XFBIxffc/RZHD8
oPIAn2O+NCdfBrGzkB9kJEHVTmX//uKk
=7LZ7
-----END PGP SIGNATURE-----
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
________________________________________________________________
erlang-bugs mailing list. See http://www.erlang.org/faq.html
erlang-bugs (at) erlang.org
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
Post received from mailinglist |
|
|
| Back to top |
|
| partizan |
Posted: Sun Jan 10, 2010 6:53 pm |
|
|
|
Joined: 07 Sep 2009
Posts: 2
|
On Sun, Jan 10, 2010 at 19:58, Ulf Wiger wrote:
> Alexander Borovsky wrote:
>> Release: R13B03
>>
>> Steps to reproduce:
>> 1) erlang:list_to_float("42")
>>
>> Expected result:
>> 42.0 (float)
>>
>> Actual result:
>> error:badarg
>
> Arguably, this is in line with the documented behaviour:
>
> "list_to_float(String) -> float()
>
> Types:
> String = string()
>
> Returns the float whose text representation is String.
>
>> list_to_float("2.2017764e+0").
> 2.2017764
>
> Failure: badarg if String contains a bad representation of a float."
>
>
> There is no float that has the text representation "42".
42.0 could have text representation "42".
In most languages (C, Java, Ruby, etc) "42" parsed to float with no errors.
Also in some cases float values could be outputted with no decimal point:
In C:
#include<stdio.h>
int main() {
double d = 42;
printf("%g\n", d);
return 0;
}
will print "42"
So integers should be properly parsed by list_to_float() function (as
corresponding float value)
--
With best regards,
Alexander Borovsky
________________________________________________________________
erlang-bugs mailing list. See http://www.erlang.org/faq.html
erlang-bugs (at) erlang.org
Post received from mailinglist |
|
|
| Back to top |
|
| FredrikSvahn |
Posted: Sun Jan 10, 2010 7:29 pm |
|
|
|
User
Joined: 19 Jun 2007
Posts: 31
|
See: http://old.nabble.com/list_to_float%28%29-td19309221.html
BR /Fredrik
On Sun, Jan 10, 2010 at 7:53 PM, Alexander Borovsky
<alex.borovsky@gmail.com> wrote:
> On Sun, Jan 10, 2010 at 19:58, Ulf Wiger wrote:
>
>> Alexander Borovsky wrote:
>>> Release: R13B03
>>>
>>> Steps to reproduce:
>>> 1) erlang:list_to_float("42")
>>>
>>> Expected result:
>>> 42.0 (float)
>>>
>>> Actual result:
>>> error:badarg
>>
>> Arguably, this is in line with the documented behaviour:
>>
>> "list_to_float(String) -> float()
>>
>> Types:
>> String = string()
>>
>> Returns the float whose text representation is String.
>>
>>> list_to_float("2.2017764e+0").
>> 2.2017764
>>
>> Failure: badarg if String contains a bad representation of a float."
>>
>>
>> There is no float that has the text representation "42".
>
> 42.0 could have text representation "42".
>
> In most languages (C, Java, Ruby, etc) "42" parsed to float with no errors.
>
> Also in some cases float values could be outputted with no decimal point:
>
> In C:
> #include<stdio.h>
>
> int main() {
> |
|
|
| Back to top |
|
| uwiger |
Posted: Sun Jan 10, 2010 7:31 pm |
|
|
|
User
Joined: 03 Jul 2006
Posts: 604
Location: Sweden
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alexander Borovsky wrote:
>
> 42.0 could have text representation "42".
>
> In most languages (C, Java, Ruby, etc) "42" parsed to float with no errors.
>
> Also in some cases float values could be outputted with no decimal point:
This is why I wrote "arguably".
The question has been up on the mailing list before:
http://www.erlang.org/cgi-bin/ezmlm-cgi?4:msp:15372:bkelgefglpkakhbedlbf
(May 12 2005)
http://www.erlang.org/cgi-bin/ezmlm-cgi/4/27647 (Jul 3 2007)
http://www.erlang.org/cgi-bin/ezmlm-cgi/4/37899 (Sep 4 2008)
In the last one, Richard Carlsson wrote:
It's a "feature": list_to_float/1 is a rather low level function,
which assumes that you have already checked that the string has the
proper form for an Erlang float, i.e., "0.0" and "1.0E-3" are ok,
but "22", ".0", and "0." are not.
But you're definitely not the first one to disagree with this design
decision.
BR,
UlfW
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAktKKwoACgkQtqqFieqzed3PSACfVOYTeSt9isb25zYygZg9RCXw
hGYAoKfAiYDMXnaljZh8gbPDmRVBZM1C
=0fkq
-----END PGP SIGNATURE-----
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
________________________________________________________________
erlang-bugs mailing list. See http://www.erlang.org/faq.html
erlang-bugs (at) erlang.org
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
Post received from mailinglist |
|
|
| Back to top |
|
| rvirding |
Posted: Mon Jan 11, 2010 6:35 pm |
|
|
|
User
Joined: 30 Aug 2006
Posts: 452
Location: Stockholm, Sweden
|
2010/1/10 Ulf Wiger <ulf.wiger@erlang-consulting.com>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Alexander Borovsky wrote:
> >
> > 42.0 could have text representation "42".
> >
> > In most languages (C, Java, Ruby, etc) "42" parsed to float with no
> errors.
> >
> > Also in some cases float values could be outputted with no decimal point:
>
> This is why I wrote "arguably".
>
> The question has been up on the mailing list before:
>
> http://www.erlang.org/cgi-bin/ezmlm-cgi?4:msp:15372:bkelgefglpkakhbedlbf
> (May 12 2005)
> http://www.erlang.org/cgi-bin/ezmlm-cgi/4/27647 (Jul 3 2007)
> http://www.erlang.org/cgi-bin/ezmlm-cgi/4/37899 (Sep 4 2008)
>
> In the last one, Richard Carlsson wrote:
>
> It's a "feature": list_to_float/1 is a rather low level function,
> which assumes that you have already checked that the string has the
> proper form for an Erlang float, i.e., "0.0" and "1.0E-3" are ok,
> but "22", ".0", and "0." are not.
>
> But you're definitely not the first one to disagree with this design
> decision.
>
I *knew* it was a mistake to add floats in the first place. If NASA can hit
the moon without them why should we need them for a telephone exchange or
serving up a few pages on the web?
Robert
Post received from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Wed Jan 13, 2010 1:20 am |
|
|
|
Guest
|
Wings3D?
On Mon, Jan 11, 2010 at 12:34 PM, Robert Virding <rvirding@gmail.com> wrote:
> 2010/1/10 Ulf Wiger <ulf.wiger@erlang-consulting.com>
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Alexander Borovsky wrote:
> > >
> > > 42.0 could have text representation "42".
> > >
> > > In most languages (C, Java, Ruby, etc) "42" parsed to float with no
> > errors.
> > >
> > > Also in some cases float values could be outputted with no decimal
> point:
> >
> > This is why I wrote "arguably".
> >
> > The question has been up on the mailing list before:
> >
> > http://www.erlang.org/cgi-bin/ezmlm-cgi?4:msp:15372:bkelgefglpkakhbedlbf
> > (May 12 2005)
> > http://www.erlang.org/cgi-bin/ezmlm-cgi/4/27647 (Jul 3 2007)
> > http://www.erlang.org/cgi-bin/ezmlm-cgi/4/37899 (Sep 4 2008)
> >
> > In the last one, Richard Carlsson wrote:
> >
> > It's a "feature": list_to_float/1 is a rather low level function,
> > which assumes that you have already checked that the string has the
> > proper form for an Erlang float, i.e., "0.0" and "1.0E-3" are ok,
> > but "22", ".0", and "0." are not.
> >
> > But you're definitely not the first one to disagree with this design
> > decision.
> >
>
> I *knew* it was a mistake to add floats in the first place. If NASA can hit
> the moon without them why should we need them for a telephone exchange or
> serving up a few pages on the web?
>
> Robert
>
Post received from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|