On 29/10/12 22:12, alexeymuranov (Alexey Muranov) wrote:
>
> Issue #6973 has been updated by alexeymuranov (Alexey Muranov).
>
>
>>   >>    Floats are precise, just like Integers are.  *Operations* on floats are
>>   >>    not accurate, and that's where the confusion comes from.  That's
>>   >>    inherent to the representation and something you've got to deal with
>>   >>    anyway, so I certainly don't see this test as making that problem worse.
>>   >
>>   >  Your points is valid as long as we can distinguish a Float that includes
>>   >  error from a Float that includes no error, such as, just created by a
>>   >  Float literal, or by only accurate operations (no overflow, no indivisible
>>   >  division, ...).
>>   >  But in fact, we cannot distinguish them.  We conservatively have to think
>>   >  that any Float object includes an error, I think.
>>
>>   So if I knowingly and correctly construct a calculation which cannot
>>   contain such an error, Ruby should tell me that it's wrong?
>>
>
> I guess the question is: what would be a point in calling this method on a Float?  A Float value is rarely exact in the sense that it rarely coincides with the real-world value which it models.

I explained this upthread.  Float *values* are always exact.  Float 
*operations* are not.

-- 
Alex

> ----------------------------------------
> Feature #6973: Add an #integral? method to Numeric to test for whole-number values
> https://bugs.ruby-lang.org/issues/6973#change-31933
>
> Author: regularfry (Alex Young)
> Status: Assigned
> Priority: Normal
> Assignee: mrkn (Kenta Murata)
> Category: core
> Target version: next minor
>
>
> Numeric#integer? checks whether an instance is an Integer.  It is often useful to check whether the value of a non-Integer variable is actually a whole number, and the #integer? method doesn't help here.
>
> This patch adds Numeric#integral?, which performs this check.
>
>