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/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>