ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Kenta Murata <muraken@gmail.com>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:38891] [Ruby 1.9 - Bug #5179] Complex#rationalize and to_r with approximate zeros
Date: Wed, 10 Aug 2011 19:20:31 +0900	[thread overview]
Message-ID: <redmine.journal-20202.20110810192030@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-5179.20110810104115@ruby-lang.org


Issue #5179 has been updated by Kenta Murata.

Assignee set to Kenta Murata

0.0 doesn't exactly represent zero. It may be 0.0+-10.0**(Float::MIN_10_EXP-17).
BigDecimal(0) doesn't exactly represent zero, too.

I believe this issue should be resolved by introducing Numeric#exact? and/or Numeric#inexact? methods.

----------------------------------------
Bug #5179: Complex#rationalize and to_r with approximate zeros
http://redmine.ruby-lang.org/issues/5179

Author: Marc-Andre Lafortune
Status: Open
Priority: Normal
Assignee: Kenta Murata
Category: core
Target version: 
ruby -v: r32354


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?



-- 
http://redmine.ruby-lang.org

  reply	other threads:[~2011-08-10 10:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-10  1:41 [ruby-core:38886] [Ruby 1.9 - Bug #5179][Open] Complex#rationalize and to_r with approximate zeros Marc-Andre Lafortune
2011-08-10 10:20 ` Kenta Murata [this message]
2020-01-17  1:18 ` [ruby-core:96919] [Ruby master Bug#5179] " merch-redmine
2020-01-17  3:00 ` [ruby-core:96920] " mame

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-20202.20110810192030@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).