Project

General

Profile

Actions

Bug #5179

closed

Complex#rationalize and to_r with approximate zeros

Added by marcandre (Marc-Andre Lafortune) over 12 years ago. Updated about 2 months ago.

Status:
Closed
Target version:
-
ruby -v:
r32354
Backport:
[ruby-core:38886]
Tags:

Description

Currently, Complex#rationalize and Complex#to_r raise a RangeError if the imaginary part is nonzero or is a Float. Note that a BigDecimal(0) is accepted, though:

Complex(1, 0).to_r                 # => Rational(1,1)
Complex(1, BigDecimal("0.0")).to_r # => Rational(1,1)
Complex(1, 0.0).to_r               # => RangeError

This is inconsistent. I recommend not raising an error for 0.0 (Float or BigDecimal). Any objection?


Related issues 1 (0 open1 closed)

Blocked by Ruby master - Feature #5321: Introducing Numeric#exact? and Numeric#inexact?Rejectedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0