Skip to content

Instantly share code, notes, and snippets.

@kakutani
Created October 5, 2009 10:50
Show Gist options
  • Save kakutani/202048 to your computer and use it in GitHub Desktop.
Save kakutani/202048 to your computer and use it in GitHub Desktop.
ruby -v -rbigdecimal -e '%w[Infinity NaN].each{|s| v = BigDecimal.new(s); i = v.to_i rescue $!.class; print "#{v}: ";p i}'
$ /usr/bin/ruby -v -rbigdecimal -e '%w[Infinity NaN].each{|s| v = BigDecimal.new(s); i = v.to_i rescue $!.class; print "#{v}:";p i}'
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
Infinity:nil
NaN:nil
$ ruby -v -rbigdecimal -e '%w[Infinity NaN].each{|s| v = BigDecimal.new(s); i = v.to_i rescue $!.class; print "#{v}:";p i}'
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
Infinity:FloatDomainError
NaN:FloatDomainError
$ ruby19 -v -rbigdecimal -e '%w[Infinity NaN].each{|s| v = BigDecimal.new(s); i = v.to_i rescue $!.class; print "#{v}:";p i}'
ruby 1.9.2dev (2009-10-05 trunk 25235) [i386-darwin9.8.0]
Infinity:FloatDomainError
NaN:FloatDomainError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment