Project

General

Profile

Actions

Bug #22079

closed

Float#ceil gives incorrect result

Bug #22079: Float#ceil gives incorrect result

Added by cryptogopher (crypto gopher) about 21 hours ago. Updated about 8 hours ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.7 (2025-01-15 revision be31f993d7) [x86_64-linux]
[ruby-core:125565]

Description

Let's take following number as an example:

> Float::MIN
=> 2.2250738585072014e-308

This gives proper result:

> Float::MIN.ceil(308)
=> 2.9999999999999997e-308

But this does not:

> Float::MIN.floor(309)
=> NaN

even though the result is perfectly valid Float number:

> "2.3e-308".to_f
=> 2.3e-308

Updated by nobu (Nobuyoshi Nakada) about 9 hours ago Actions #1 [ruby-core:125571]

  • Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED

Updated by nobu (Nobuyoshi Nakada) about 8 hours ago Actions #2

  • Status changed from Open to Closed

Applied in changeset git|09dacb9c3d61264f3eb3731e2c65feb869130228.


[Bug #22079] Fix Float#ceil and Float#floor edge cases

Actions

Also available in: PDF Atom