Last Updated: February 25, 2016
·
483
· jiren

How to find Infinity in Ruby

1.9.3-p0 :001 > 1/0
 ZeroDivisionError: divided by 0

1.9.3-p0 :002 > 1.0/0
 => Infinity 

1.9.3-p0 :006 > -1.0/0
=> -Infinity

1.9.3-p0 :004 > Float::INFINITY
=> Infinity 

1.9.3-p0 :005 > -Float::INFINITY
=> -Infinity