Skip to content

Instantly share code, notes, and snippets.

@d11wtq
Created December 1, 2011 03:19
Show Gist options
  • Save d11wtq/1413222 to your computer and use it in GitHub Desktop.
Save d11wtq/1413222 to your computer and use it in GitHub Desktop.
Complex number representation of a decimal should be considered a real number, but is not.
[1] pry(main)> Complex("2.5")
=> (2.5+0i)
[2] pry(main)> Rational("2.5")
=> (5/2)
[3] pry(main)> Complex("2.5") == Rational("2.5")
=> true
[4] pry(main)> Complex("2.5").real?
=> false
[5] pry(main)> Rational("2.5").real?
=> true
[6] pry(main)>
@d11wtq
Copy link
Author

d11wtq commented Dec 1, 2011

Never mind. Brain fail ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment