Skip to content

Commit

Permalink
Add Numeric#nan?, Numeric#finite? and Numeric#infinite?
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Oct 17, 2013
1 parent cae238d commit c9138f4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions corelib/numeric.rb
Expand Up @@ -253,6 +253,22 @@ def size
# Just a stub, JS is 32bit for bitwise ops though
4
end

def nan?
`isNaN(self)`
end

def finite?
`self == Infinity || self == -Infinity`
end

def infinite?
if `self == Infinity`
`+1`
elsif `self == -Infinity`
`-1`
end
end
end

Fixnum = Numeric
Expand Down

0 comments on commit c9138f4

Please sign in to comment.