From: "matz (Yukihiro Matsumoto) via ruby-core" Date: 2026-07-10T01:40:33+00:00 Subject: [ruby-core:126027] [Ruby Feature#22085] `String#to_f` and `Kernel#Float` shouldn't issue out of range warnings Issue #22085 has been updated by matz (Yukihiro Matsumoto). Accepted. The out of range warning is meant for float literals in source code, where the programmer can fix the literal. For runtime conversion of user input or external data, the warning is not actionable, and the return value (`Infinity`) is already well defined. `String#to_f` and `Kernel#Float` should just return the value silently. Matz. ---------------------------------------- Feature #22085: `String#to_f` and `Kernel#Float` shouldn't issue out of range warnings https://bugs.ruby-lang.org/issues/22085#change-118006 * Author: byroot (Jean Boussier) * Status: Open ---------------------------------------- Ruby issue warnings when parsing out of range floats, e.g.: ``` $ ruby -We '1e184467440737095516160.to_s' -e:1: warning: Float 1e184467440737095516... out of range ``` This makes a lot of sense for float literals parsed by the Ruby parser. However I'm not convinced it makes sense when parsing user input or third party data: ```ruby >> '1e184467440737095516160'.to_f (irb):1: warning: Float 1e184467440737095516... out of range => Infinity >> Float('1e184467440737095516160') :196: warning: Float 1e184467440737095516... out of range => Infinity ``` As these warnings aren't really actionable in most cases. So I think `String#to_f` and `Kernel#Float` shouldn't issue out of range warnings. -- 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/