Created
December 1, 2011 03:19
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Never mind. Brain fail ;)