ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:118979] [Ruby master Feature#20705] Should "0.E-9" be a valid float value?
@ 2024-08-29  8:01 kou (Kouhei Sutou) via ruby-core
  2024-08-29  9:02 ` [ruby-core:118980] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kou (Kouhei Sutou) via ruby-core @ 2024-08-29  8:01 UTC (permalink / raw)
  To: ruby-core; +Cc: kou (Kouhei Sutou)

Issue #20705 has been reported by kou (Kouhei Sutou).

----------------------------------------
Feature #20705: Should "0.E-9" be a valid float value?
https://bugs.ruby-lang.org/issues/20705

* Author: kou (Kouhei Sutou)
* Status: Open
----------------------------------------
Ruby doesn't accept "0.E-9" as a valid float value:

```console
$ ruby -e 'Float("0.E-9")'
<internal:kernel>:218:in 'Kernel#Float': invalid value for Float(): "0.E-9" (ArgumentError)
	from -e:1:in '<main>'
```

But other systems accept "0.E-9" as a valid float value:

PostgreSQL:

```text
=> select 0.E-9;
  ?column?   
-------------
 0.000000000
(1 row)
```

MySQL:

```text
> select 0.E-9;
+-------+
| 0.E-9 |
+-------+
|     0 |
+-------+
1 row in set (0.00 sec)
```

Python:

```console
$ python3 -c 'print(0.E-9)'
0.0
```

Node.js:

```console
$ nodejs -e 'console.log(0.E-9)'
0
```

Should Ruby accept "0.E-9" as a valid float value?

FYI: I don't have an opinion of this. I just realized this by an issue from an user of a maintained library by me: https://github.com/apache/arrow/issues/43877



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:118980] [Ruby master Feature#20705] Should "0.E-9" be a valid float value?
  2024-08-29  8:01 [ruby-core:118979] [Ruby master Feature#20705] Should "0.E-9" be a valid float value? kou (Kouhei Sutou) via ruby-core
@ 2024-08-29  9:02 ` nobu (Nobuyoshi Nakada) via ruby-core
  2024-08-29  9:10 ` [ruby-core:118981] " mame (Yusuke Endoh) via ruby-core
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2024-08-29  9:02 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #20705 has been updated by nobu (Nobuyoshi Nakada).


It feels reasonable to relax the `to_f` conversion.

Regarding Python and Node.js examples, they are literals and different things, I think.


----------------------------------------
Feature #20705: Should "0.E-9" be a valid float value?
https://bugs.ruby-lang.org/issues/20705#change-109552

* Author: kou (Kouhei Sutou)
* Status: Open
----------------------------------------
Ruby doesn't accept "0.E-9" as a valid float value:

```console
$ ruby -e 'Float("0.E-9")'
<internal:kernel>:218:in 'Kernel#Float': invalid value for Float(): "0.E-9" (ArgumentError)
	from -e:1:in '<main>'
```

But other systems accept "0.E-9" as a valid float value:

PostgreSQL:

```text
=> select 0.E-9;
  ?column?   
-------------
 0.000000000
(1 row)
```

MySQL:

```text
> select 0.E-9;
+-------+
| 0.E-9 |
+-------+
|     0 |
+-------+
1 row in set (0.00 sec)
```

Python:

```console
$ python3 -c 'print(0.E-9)'
0.0
```

Node.js:

```console
$ nodejs -e 'console.log(0.E-9)'
0
```

Should Ruby accept "0.E-9" as a valid float value?

FYI: I don't have an opinion of this. I just realized this by an issue from an user of a maintained library by me: https://github.com/apache/arrow/issues/43877



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:118981] [Ruby master Feature#20705] Should "0.E-9" be a valid float value?
  2024-08-29  8:01 [ruby-core:118979] [Ruby master Feature#20705] Should "0.E-9" be a valid float value? kou (Kouhei Sutou) via ruby-core
  2024-08-29  9:02 ` [ruby-core:118980] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2024-08-29  9:10 ` mame (Yusuke Endoh) via ruby-core
  2024-08-29 14:10 ` [ruby-core:118982] " Hanmac (Hans Mackowiak) via ruby-core
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2024-08-29  9:10 UTC (permalink / raw)
  To: ruby-core; +Cc: mame (Yusuke Endoh)

Issue #20705 has been updated by mame (Yusuke Endoh).


Note that they also treat `0.` as a floating point number literal.


```
$ python3 -c 'print(0.)'
0.0


$ node -e 'console.log(0.)'
0
```

----------------------------------------
Feature #20705: Should "0.E-9" be a valid float value?
https://bugs.ruby-lang.org/issues/20705#change-109553

* Author: kou (Kouhei Sutou)
* Status: Open
----------------------------------------
Ruby doesn't accept "0.E-9" as a valid float value:

```console
$ ruby -e 'Float("0.E-9")'
<internal:kernel>:218:in 'Kernel#Float': invalid value for Float(): "0.E-9" (ArgumentError)
	from -e:1:in '<main>'
```

But other systems accept "0.E-9" as a valid float value:

PostgreSQL:

```text
=> select 0.E-9;
  ?column?   
-------------
 0.000000000
(1 row)
```

MySQL:

```text
> select 0.E-9;
+-------+
| 0.E-9 |
+-------+
|     0 |
+-------+
1 row in set (0.00 sec)
```

Python:

```console
$ python3 -c 'print(0.E-9)'
0.0
```

Node.js:

```console
$ nodejs -e 'console.log(0.E-9)'
0
```

Should Ruby accept "0.E-9" as a valid float value?

FYI: I don't have an opinion of this. I just realized this by an issue from an user of a maintained library by me: https://github.com/apache/arrow/issues/43877



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:118982] [Ruby master Feature#20705] Should "0.E-9" be a valid float value?
  2024-08-29  8:01 [ruby-core:118979] [Ruby master Feature#20705] Should "0.E-9" be a valid float value? kou (Kouhei Sutou) via ruby-core
  2024-08-29  9:02 ` [ruby-core:118980] " nobu (Nobuyoshi Nakada) via ruby-core
  2024-08-29  9:10 ` [ruby-core:118981] " mame (Yusuke Endoh) via ruby-core
@ 2024-08-29 14:10 ` Hanmac (Hans Mackowiak) via ruby-core
  2024-09-05  8:49 ` [ruby-core:119061] " matz (Yukihiro Matsumoto) via ruby-core
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Hanmac (Hans Mackowiak) via ruby-core @ 2024-08-29 14:10 UTC (permalink / raw)
  To: ruby-core; +Cc: Hanmac (Hans Mackowiak)

Issue #20705 has been updated by Hanmac (Hans Mackowiak).


we need to be careful with this, because while `0.1E-9` is also a valid ruby literal,
`0.E-9` is not. (unknown method E for 0)
`1E-9` is valid literal again

----------------------------------------
Feature #20705: Should "0.E-9" be a valid float value?
https://bugs.ruby-lang.org/issues/20705#change-109556

* Author: kou (Kouhei Sutou)
* Status: Open
----------------------------------------
Ruby doesn't accept "0.E-9" as a valid float value:

```console
$ ruby -e 'Float("0.E-9")'
<internal:kernel>:218:in 'Kernel#Float': invalid value for Float(): "0.E-9" (ArgumentError)
	from -e:1:in '<main>'
```

But other systems accept "0.E-9" as a valid float value:

PostgreSQL:

```text
=> select 0.E-9;
  ?column?   
-------------
 0.000000000
(1 row)
```

MySQL:

```text
> select 0.E-9;
+-------+
| 0.E-9 |
+-------+
|     0 |
+-------+
1 row in set (0.00 sec)
```

Python:

```console
$ python3 -c 'print(0.E-9)'
0.0
```

Node.js:

```console
$ nodejs -e 'console.log(0.E-9)'
0
```

Should Ruby accept "0.E-9" as a valid float value?

FYI: I don't have an opinion of this. I just realized this by an issue from an user of a maintained library by me: https://github.com/apache/arrow/issues/43877



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:119061] [Ruby master Feature#20705] Should "0.E-9" be a valid float value?
  2024-08-29  8:01 [ruby-core:118979] [Ruby master Feature#20705] Should "0.E-9" be a valid float value? kou (Kouhei Sutou) via ruby-core
                   ` (2 preceding siblings ...)
  2024-08-29 14:10 ` [ruby-core:118982] " Hanmac (Hans Mackowiak) via ruby-core
@ 2024-09-05  8:49 ` matz (Yukihiro Matsumoto) via ruby-core
  2024-09-05  9:05 ` [ruby-core:119063] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2024-09-05  8:49 UTC (permalink / raw)
  To: ruby-core; +Cc: matz (Yukihiro Matsumoto)

Issue #20705 has been updated by matz (Yukihiro Matsumoto).


We are not going to change the literal format of floating point values. But I think it's good to make Float/to_f to accept "0.e-9".

Matz.


----------------------------------------
Feature #20705: Should "0.E-9" be a valid float value?
https://bugs.ruby-lang.org/issues/20705#change-109639

* Author: kou (Kouhei Sutou)
* Status: Open
----------------------------------------
Ruby doesn't accept "0.E-9" as a valid float value:

```console
$ ruby -e 'Float("0.E-9")'
<internal:kernel>:218:in 'Kernel#Float': invalid value for Float(): "0.E-9" (ArgumentError)
	from -e:1:in '<main>'
```

But other systems accept "0.E-9" as a valid float value:

PostgreSQL:

```text
=> select 0.E-9;
  ?column?   
-------------
 0.000000000
(1 row)
```

MySQL:

```text
> select 0.E-9;
+-------+
| 0.E-9 |
+-------+
|     0 |
+-------+
1 row in set (0.00 sec)
```

Python:

```console
$ python3 -c 'print(0.E-9)'
0.0
```

Node.js:

```console
$ nodejs -e 'console.log(0.E-9)'
0
```

Should Ruby accept "0.E-9" as a valid float value?

FYI: I don't have an opinion of this. I just realized this by an issue from an user of a maintained library by me: https://github.com/apache/arrow/issues/43877



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:119063] [Ruby master Feature#20705] Should "0.E-9" be a valid float value?
  2024-08-29  8:01 [ruby-core:118979] [Ruby master Feature#20705] Should "0.E-9" be a valid float value? kou (Kouhei Sutou) via ruby-core
                   ` (3 preceding siblings ...)
  2024-09-05  8:49 ` [ruby-core:119061] " matz (Yukihiro Matsumoto) via ruby-core
@ 2024-09-05  9:05 ` nobu (Nobuyoshi Nakada) via ruby-core
  2024-09-06  2:48 ` [ruby-core:119077] " kou (Kouhei Sutou) via ruby-core
  2024-09-06  8:06 ` [ruby-core:119083] " mrkn (Kenta Murata) via ruby-core
  6 siblings, 0 replies; 8+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2024-09-05  9:05 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #20705 has been updated by nobu (Nobuyoshi Nakada).


It seems a bug in missing/dtoa.c.

----------------------------------------
Feature #20705: Should "0.E-9" be a valid float value?
https://bugs.ruby-lang.org/issues/20705#change-109641

* Author: kou (Kouhei Sutou)
* Status: Open
----------------------------------------
Ruby doesn't accept "0.E-9" as a valid float value:

```console
$ ruby -e 'Float("0.E-9")'
<internal:kernel>:218:in 'Kernel#Float': invalid value for Float(): "0.E-9" (ArgumentError)
	from -e:1:in '<main>'
```

But other systems accept "0.E-9" as a valid float value:

PostgreSQL:

```text
=> select 0.E-9;
  ?column?   
-------------
 0.000000000
(1 row)
```

MySQL:

```text
> select 0.E-9;
+-------+
| 0.E-9 |
+-------+
|     0 |
+-------+
1 row in set (0.00 sec)
```

Python:

```console
$ python3 -c 'print(0.E-9)'
0.0
```

Node.js:

```console
$ nodejs -e 'console.log(0.E-9)'
0
```

Should Ruby accept "0.E-9" as a valid float value?

FYI: I don't have an opinion of this. I just realized this by an issue from an user of a maintained library by me: https://github.com/apache/arrow/issues/43877



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:119077] [Ruby master Feature#20705] Should "0.E-9" be a valid float value?
  2024-08-29  8:01 [ruby-core:118979] [Ruby master Feature#20705] Should "0.E-9" be a valid float value? kou (Kouhei Sutou) via ruby-core
                   ` (4 preceding siblings ...)
  2024-09-05  9:05 ` [ruby-core:119063] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2024-09-06  2:48 ` kou (Kouhei Sutou) via ruby-core
  2024-09-06  8:06 ` [ruby-core:119083] " mrkn (Kenta Murata) via ruby-core
  6 siblings, 0 replies; 8+ messages in thread
From: kou (Kouhei Sutou) via ruby-core @ 2024-09-06  2:48 UTC (permalink / raw)
  To: ruby-core; +Cc: kou (Kouhei Sutou)

Issue #20705 has been updated by kou (Kouhei Sutou).


Implementation: https://github.com/ruby/ruby/pull/11559

Should we also accept "0." as @mame showed in #2? The implementation includes "0." support.

FYI: to_f already accepts "0.". Float didn't accept "0.".

----------------------------------------
Feature #20705: Should "0.E-9" be a valid float value?
https://bugs.ruby-lang.org/issues/20705#change-109661

* Author: kou (Kouhei Sutou)
* Status: Open
----------------------------------------
Ruby doesn't accept "0.E-9" as a valid float value:

```console
$ ruby -e 'Float("0.E-9")'
<internal:kernel>:218:in 'Kernel#Float': invalid value for Float(): "0.E-9" (ArgumentError)
	from -e:1:in '<main>'
```

But other systems accept "0.E-9" as a valid float value:

PostgreSQL:

```text
=> select 0.E-9;
  ?column?   
-------------
 0.000000000
(1 row)
```

MySQL:

```text
> select 0.E-9;
+-------+
| 0.E-9 |
+-------+
|     0 |
+-------+
1 row in set (0.00 sec)
```

Python:

```console
$ python3 -c 'print(0.E-9)'
0.0
```

Node.js:

```console
$ nodejs -e 'console.log(0.E-9)'
0
```

Should Ruby accept "0.E-9" as a valid float value?

FYI: I don't have an opinion of this. I just realized this by an issue from an user of a maintained library by me: https://github.com/apache/arrow/issues/43877



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:119083] [Ruby master Feature#20705] Should "0.E-9" be a valid float value?
  2024-08-29  8:01 [ruby-core:118979] [Ruby master Feature#20705] Should "0.E-9" be a valid float value? kou (Kouhei Sutou) via ruby-core
                   ` (5 preceding siblings ...)
  2024-09-06  2:48 ` [ruby-core:119077] " kou (Kouhei Sutou) via ruby-core
@ 2024-09-06  8:06 ` mrkn (Kenta Murata) via ruby-core
  6 siblings, 0 replies; 8+ messages in thread
From: mrkn (Kenta Murata) via ruby-core @ 2024-09-06  8:06 UTC (permalink / raw)
  To: ruby-core; +Cc: mrkn (Kenta Murata)

Issue #20705 has been updated by mrkn (Kenta Murata).


Changing `String#to_f` introduces incompatibility:

```
$ ruby -ve "p '1.e-9'.to_f"
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [x86_64-linux]
1.0
```

----------------------------------------
Feature #20705: Should "0.E-9" be a valid float value?
https://bugs.ruby-lang.org/issues/20705#change-109669

* Author: kou (Kouhei Sutou)
* Status: Open
----------------------------------------
Ruby doesn't accept "0.E-9" as a valid float value:

```console
$ ruby -e 'Float("0.E-9")'
<internal:kernel>:218:in 'Kernel#Float': invalid value for Float(): "0.E-9" (ArgumentError)
	from -e:1:in '<main>'
```

But other systems accept "0.E-9" as a valid float value:

PostgreSQL:

```text
=> select 0.E-9;
  ?column?   
-------------
 0.000000000
(1 row)
```

MySQL:

```text
> select 0.E-9;
+-------+
| 0.E-9 |
+-------+
|     0 |
+-------+
1 row in set (0.00 sec)
```

Python:

```console
$ python3 -c 'print(0.E-9)'
0.0
```

Node.js:

```console
$ nodejs -e 'console.log(0.E-9)'
0
```

Should Ruby accept "0.E-9" as a valid float value?

FYI: I don't have an opinion of this. I just realized this by an issue from an user of a maintained library by me: https://github.com/apache/arrow/issues/43877



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-09-06  8:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-29  8:01 [ruby-core:118979] [Ruby master Feature#20705] Should "0.E-9" be a valid float value? kou (Kouhei Sutou) via ruby-core
2024-08-29  9:02 ` [ruby-core:118980] " nobu (Nobuyoshi Nakada) via ruby-core
2024-08-29  9:10 ` [ruby-core:118981] " mame (Yusuke Endoh) via ruby-core
2024-08-29 14:10 ` [ruby-core:118982] " Hanmac (Hans Mackowiak) via ruby-core
2024-09-05  8:49 ` [ruby-core:119061] " matz (Yukihiro Matsumoto) via ruby-core
2024-09-05  9:05 ` [ruby-core:119063] " nobu (Nobuyoshi Nakada) via ruby-core
2024-09-06  2:48 ` [ruby-core:119077] " kou (Kouhei Sutou) via ruby-core
2024-09-06  8:06 ` [ruby-core:119083] " mrkn (Kenta Murata) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).