Project

General

Profile

Actions

Bug #20873

closed

`printf("%f")` returns wrong result for `Rational` with `FIXNUM_MIN`

Added by nobu (Nobuyoshi Nakada) 15 days ago. Updated 11 days ago.

Status:
Closed
Target version:
-
[ruby-core:119764]

Description

Since the beginning, ruby 2.3.

require 'rbconfig/sizeof'
fmin, fmax = RbConfig::LIMITS.values_at("FIXNUM_MIN", "FIXNUM_MAX")
sprintf("%f", Rational(fmin, fmax)) #=> --1.000000

Updated by nobu (Nobuyoshi Nakada) 15 days ago

  • Assignee set to nobu (Nobuyoshi Nakada)
  • Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN to 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED
Actions #2

Updated by nobu (Nobuyoshi Nakada) 15 days ago

  • Status changed from Open to Closed

Applied in changeset git|d71be7274bd2623bb521be72c245c08fc38d6ae4.


[Bug #20873] Consider -FIXNUM_MIN overflow

-FIXNUM_MIN is usually greater than FIXNUM_MAX on platforms using
two's complement representation.

Updated by nagachika (Tomoyuki Chikanaga) 11 days ago

  • Backport changed from 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED to 3.1: REQUIRED, 3.2: DONE, 3.3: REQUIRED
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0