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 valuea = -100.7 # Declaring float valueb = -100.70 # Declaring float valuec = 100.7 # Check array equalityputs "a = b : #{a.eql?(b)}\n\n" # Check array equalityputs "b = c : #{b.eql?(c)}\n\n" # Check array equalityputs "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 valuea = 10070 # Declaring float valueb = 10070 # Declaring float valuec = 10070.0 # Check array equalityputs "a = b : #{a.eql?(b)}\n\n" # Check array equalityputs "b = c : #{b.eql?(c)}\n\n" # Check array equalityputs "c = b : #{c.eql?(b)}\n\n" |
Output :
a = b : true b = c : false c = b : false

