On 30/10/11 12:29, Alexey Muranov wrote:
> 
> Issue #5321 has been updated by Alexey Muranov.
> 
> 
> Charles, this is from the documentation of BigDecimal: "If a computation results in a value which is too small to be represented as a BigDecimal within the currently specified limits of precision, zero must be returned.".
> Thus the operations on BigDecimal are not exact. (See also BigDecimal::ROUND_MODE.)
> 
> For me it is easier to think simply whether a class is *intended* to represent numbers exactly. The formal definition of exactness probably is the following: "Each operation must be carried out exactly or return NaN or nil, or return some other *exceptional* value."

The problem with this is that the values *are* exact, and *some* of the
operations are inexact.  Some of the operations are *sometimes* inexact.
 Flagging a class at a time as exact or inexact just sounds wrong to me.
 Better would be flagging values that have had inexact operations
performed on them (or exact operations with an inexact operand) at any
time in their history, but I've no idea how you'd do that while keeping
any sort of respectable performance.

-- 
Alex

> 
> -Alexey.
> ----------------------------------------
> Feature #5321: Introducing Numeric#exact? and Numeric#inexact?
> http://redmine.ruby-lang.org/issues/5321
> 
> Author: Kenta Murata
> Status: Open
> Priority: Normal
> Assignee: Yukihiro Matsumoto
> Category: 
> 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.
> 
> 
>