Project

General

Profile

Actions

Bug #13599

closed

Float#ceil(n) doesn't work for small floats

Added by Jalada (David Somers) almost 7 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:81394]

Description

When using ceil to round up to n digits (as opposed to nearest integer) with the optional first argument, it doesn't work for very small floats:

2.4.1 :001 > 0.0000000001.ceil(1)
 => 0.0   # => Expected output: 0.1

# Doing it by hand:
2.4.1 :002 > (0.0000000001 * 10).ceil / 10.0
 => 0.1
Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 7 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r58913.


numeric.c: fix for small number

Actions #2

Updated by nagachika (Tomoyuki Chikanaga) almost 7 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: REQUIRED
Actions #3

Updated by usa (Usaku NAKAMURA) almost 7 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 6 years ago

  • Backport changed from 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONE

ruby_2_4 r59505 merged revision(s) 58913.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0