ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: merch-redmine@jeremyevans.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:94087] [Ruby master Feature#5321] Introducing Numeric#exact? and Numeric#inexact?
Date: Thu, 01 Aug 2019 01:02:33 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-80318.20190801010232.d5997dd4b33a9041@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-5321.20110914132016@ruby-lang.org

Issue #5321 has been updated by jeremyevans0 (Jeremy Evans).

File numeric-exact-5321.patch added

Attached is a patch to implement `Numeric#exact?`.  This returns true for Integer and Rational, and false for Float and BigDecimal.  For Complex, it returns true if the real and imaginary parts are both true, and false otherwise (one reason `exact?` needs to be an instance method and not a class method).

This feature is necessary to fix #5179, as BigDecimal is not a core class and Complex cannot know whether or not it is exact.

----------------------------------------
Feature #5321: Introducing Numeric#exact? and Numeric#inexact?
https://bugs.ruby-lang.org/issues/5321#change-80318

* Author: mrkn (Kenta Murata)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
Ruby has several numeric classes such as Integer.
These classes are classified whether their instances represent numbers exactly.
According to this, Integer and Rational are exact, and Float and BigDecimal are inexact because they're always including error.
The exactness of a Complex depends on its real and imaginary parts.

Now, Ruby's numeric classes doesn't provide predicators to investigate the exactness of their instances.
So, if we want to examine whether a number is exactly zero, we must investigate the class of the number.
I want simple way to examine the number exactness.

I propose to introduce Numeric#exact? and/or Numeric#inexact? for resolving this inconvenience.


---Files--------------------------------
numeric-exact-5321.patch (7.33 KB)


-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2019-08-01  1:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-14  4:20 [ruby-core:39539] [Ruby 1.9 - Feature #5321][Open] Introducing Numeric#exact? and Numeric#inexact? Kenta Murata
2011-10-29 22:09 ` [ruby-core:40514] [ruby-trunk - Feature #5321] " Alexey Muranov
2011-10-29 23:57 ` [ruby-core:40519] " Charles Nutter
2011-10-30 12:29 ` [ruby-core:40524] " Alexey Muranov
2011-10-31 11:04   ` [ruby-core:40553] " Alex Young
2011-10-31 12:13 ` [ruby-core:40555] [ruby-trunk - Feature #5321][Assigned] " Yusuke Endoh
2011-10-31 12:55 ` [ruby-core:40556] [ruby-trunk - Feature #5321] " Yusuke Endoh
2011-10-31 13:21 ` [ruby-core:40557] " Alexey Muranov
2011-10-31 13:32 ` [ruby-core:40558] " Kenta Murata
2011-10-31 13:54 ` [ruby-core:40559] " tadayoshi funaba
2011-10-31 14:34   ` [ruby-core:40565] " Yusuke Endoh
2011-10-31 13:55 ` [ruby-core:40560] " Kenta Murata
2011-10-31 14:24   ` [ruby-core:40563] " Yusuke Endoh
2011-10-31 14:13 ` [ruby-core:40561] " Alexey Muranov
2011-10-31 14:54 ` [ruby-core:40566] " Kenta Murata
2011-10-31 14:59 ` [ruby-core:40567] " tadayoshi funaba
2011-10-31 15:32 ` [ruby-core:40570] " Alexey Muranov
2011-11-01 12:14 ` [ruby-core:40622] [ruby-trunk - Feature #5321][Assigned] " Masaya Tarui
2012-11-20 11:55 ` [ruby-core:49681] [ruby-trunk - Feature #5321] " mame (Yusuke Endoh)
2019-08-01  1:02 ` merch-redmine [this message]
2020-01-04  6:27 ` [ruby-core:96652] [Ruby master Feature#5321] " wishdev
2020-01-15  2:23 ` [ruby-core:96861] " akr
2020-01-15  2:43 ` [ruby-core:96863] " sawadatsuyoshi
2020-01-15  3:03 ` [ruby-core:96864] " akr
2020-01-15  6:19 ` [ruby-core:96868] " sawadatsuyoshi
2020-01-16  8:04 ` [ruby-core:96899] " matz

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-80318.20190801010232.d5997dd4b33a9041@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).