From: "mrkn (Kenta Murata) via ruby-core" Date: 2024-09-06T08:06:59+00:00 Subject: [ruby-core:119083] [Ruby master Feature#20705] Should "0.E-9" be a valid float value? 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")' :218:in 'Kernel#Float': invalid value for Float(): "0.E-9" (ArgumentError) from -e:1:in '
' ``` 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/