Last active
August 29, 2015 14:13
-
-
Save huezoaa/f4215258dca26fe96482 to your computer and use it in GitHub Desktop.
Mad_Max
This file contains 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
def max(num1, num2) | |
num1 > num2 ? num1 : num2 | |
end | |
def test # Assume all entries are numeric | |
p max(1,2) == 2 # (Fixnum, Fixnum) | |
p max(2,1) == 2 # (Fixnum, Fixnum) | |
p max(0.1, 0.2) == 0.2 # (Float, Float) | |
p max(0.2, 0.1) == 0.2 # (Float, Float) | |
p max(1,1.1) == 1.1 # (Fixnum, Float) | |
p max(1.1,1) == 1.1 # ==> num1 num1 > num2 (Float, Fixnum) | |
p max(0.99999991, 0.99993999999999999) == 0.99999991 # ==> 0.99999991 Float, Float, Lots of decimal places | |
p max(-1, 1) == 1 # ==> 1 Fixnum, Fixnum, Negative, Positive | |
p max(2, -2) == 2 # ==> 2 Fixnum, Fixnum, Positve, Negative | |
p max(1,1) == 1 # ==> 1 Fixnum, Fixnum, Equal values positive | |
p max(-2, -2) == -2 # ==> -2 Fixnum, Fixnum, Equal values negative | |
p max(10, 20) == 20 # ==> 20 Fixnum, Fixnum, Positive, Positive | |
p max(-10, -20) == -10 # ==> -10 Fixnum, Fixnum, Negative, Negative | |
p max(-99.99, 99.99) == 99.99 # ==> 99.99 Float, Float, Negative, Positive | |
p max(99.99,-199) == 99.99 # ==> 99.99 Float, Float, Positive, Negative | |
p max(199.99,199.99) == 199.99 # ==> 199.99Float, Float, Equal values positve | |
p max(-199.99,-199.99) == -199.99 # Float, Float, Equal values negative | |
p max(107.90, 107.90) == 107.90 # Float, Float, Positive, Positive | |
p max(-3.00, -3.00) == -3.00 # Float, Float, Negative, Negative | |
p max(0,0) == 0 # Fixnum, Fixnum, 0, 0 | |
p max(0,0.0) == 0 # Fixnum, Float, 0, 0.0 --> interesting result | |
p max(0.0,0) == 0 # Float, Fixnum, 0.0, 0 --> result is different than above! | |
p max(0.0, 0.0) == 0.0 # Float, Float, 0.0, 0.0 | |
end | |
test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment