[ruby-core:125565] [Ruby Bug#22079] Float#ceil gives incorrect result
Issue #22079 has been reported by cryptogopher (crypto gopher). ---------------------------------------- Bug #22079: Float#ceil gives incorrect result https://bugs.ruby-lang.org/issues/22079 * Author: cryptogopher (crypto gopher) * Status: Open * ruby -v: ruby 3.3.7 (2025-01-15 revision be31f993d7) [x86_64-linux] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Let's take following number as an example: ``` ruby
Float::MIN => 2.2250738585072014e-308
This gives proper result:
```ruby
> Float::MIN.ceil(308)
=> 2.9999999999999997e-308
But this does not: ```ruby
Float::MIN.floor(309) => NaN
even though the result is perfectly valid `Float` number:
```ruby
> "2.3e-308".to_f
=> 2.3e-308
Issue #22079 has been updated by nobu (Nobuyoshi Nakada). Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED [GH-17097](https://github.com/ruby/ruby/pull/17097) ---------------------------------------- Bug #22079: Float#ceil gives incorrect result https://bugs.ruby-lang.org/issues/22079#change-117400 * Author: cryptogopher (crypto gopher) * Status: Open * ruby -v: ruby 3.3.7 (2025-01-15 revision be31f993d7) [x86_64-linux] * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- Let's take following number as an example: ``` ruby
Float::MIN => 2.2250738585072014e-308
This gives proper result:
```ruby
> Float::MIN.ceil(308)
=> 2.9999999999999997e-308
But this does not: ```ruby
Float::MIN.floor(309) => NaN
even though the result is perfectly valid `Float` number:
```ruby
> "2.3e-308".to_f
=> 2.3e-308
Issue #22079 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE to 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ruby_3_4 commit:bc5e9ac4cf2f416435c8aac778ba272ac0205d5a merged revision(s) commit:97ec327efc74b0df42421fa4344d1f05452d0623, commit:09dacb9c3d61264f3eb3731e2c65feb869130228. ---------------------------------------- Bug #22079: Float#ceil gives incorrect result https://bugs.ruby-lang.org/issues/22079#change-117635 * Author: cryptogopher (crypto gopher) * Status: Closed * ruby -v: ruby 3.3.7 (2025-01-15 revision be31f993d7) [x86_64-linux] * Backport: 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ---------------------------------------- Let's take following number as an example: ``` ruby
Float::MIN => 2.2250738585072014e-308
This gives proper result:
```ruby
> Float::MIN.ceil(308)
=> 2.9999999999999997e-308
But this does not: ```ruby
Float::MIN.floor(309) => NaN
even though the result is perfectly valid `Float` number:
```ruby
> "2.3e-308".to_f
=> 2.3e-308
participants (3)
-
cryptogopher (crypto gopher) -
nagachika (Tomoyuki Chikanaga) -
nobu (Nobuyoshi Nakada)