Issue #6973 has been updated by jballanc (Joshua Ballanco).


=begin
> 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.

Ok, fair point. Ruby already doesn't protect you from a lack of knowledge of floats, so I can accept that this method wouldn't either.

>  This came up in #6958, specifically because BigDecimal's #integer? as 
> inherited from Numeric is confusing.
...
>  Sure.  Interface before implementation.

Actually, as I got to thinking about this, I think the variety of different ways this can be determined efficiently for different numeric types might justify having this as a method. That, of course, presupposes that each numeric type gets a concrete, efficient implementation.
=end
----------------------------------------
Feature #6973: Add an #integral? method to Numeric to test for whole-number values
https://bugs.ruby-lang.org/issues/6973#change-29192

Author: regularfry (Alex Young)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 2.0.0


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.


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