Issue #5321 has been updated by akr (Akira Tanaka).


sawa (Tsuyoshi Sawada) wrote:
> akr (Akira Tanaka) wrote:
> > I think associating class with exactness is wrong idea.
> > ...
> > I think exactness and inexactness is a property of a method, not class.
> 
> But notice that these operations are binary operations, not unary. You cannot talk about just `Integer#+` or `Float#+`, etc. You have to think about integer + integer, float + integer, integer + float, float + float, etc. And float + integer and integer + float are the same as float + float with respect to exactness. The reason should be attributed to some notion of hierarchy of exactness between the classes; float is less exact than integer, and the exactness of + would be the minimum exactness of the operands on both sides.

I see.
I wrongly assumed integer + integer for Integer#+.

> Hence, at least, the classes should also need to carry some kind of notion of exactness.

Do you have good definition of exactness of numeric classes?


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

* 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>