Ruby | Float eql() method
eql() is a float class method which checks whether two values are equal.
Syntax: float.eql()
Parameter: float values which is to be checked
Return: Boolean value
return true if values are equal otherwise return false
Example #1 :
# Ruby code for equal() method # Declaring float value a = - 100 . 7 # Declaring float value b = - 100 . 70 # Declaring float value c = 100 . 7 # Check array equality puts "a = b : #{a.eql?(b)}\n\n" # Check array equality puts "b = c : #{b.eql?(c)}\n\n" # Check array equality puts "c = b : #{c.eql?(b)}\n\n" |
Output :
a = b : true b = c : false c = b : false
Example #2 :
# Ruby code for equal() method # declaring float value a = 10070 # Declaring float value b = 10070 # Declaring float value c = 10070 . 0 # Check array equality puts "a = b : #{a.eql?(b)}\n\n" # Check array equality puts "b = c : #{b.eql?(c)}\n\n" # Check array equality puts "c = b : #{c.eql?(b)}\n\n" |
Output :
a = b : true b = c : false c = b : false