Ruby | Float eql() method
Last Updated :
08 Jan, 2020
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 :
a = - 100 . 7
b = - 100 . 70
c = 100 . 7
puts "a = b : #{a.eql?(b)}\n\n"
puts "b = c : #{b.eql?(c)}\n\n"
puts "c = b : #{c.eql?(b)}\n\n"
|
Output :
a = b : true
b = c : false
c = b : false
Example #2 :
a = 10070
b = 10070
c = 10070 . 0
puts "a = b : #{a.eql?(b)}\n\n"
puts "b = c : #{b.eql?(c)}\n\n"
puts "c = b : #{c.eql?(b)}\n\n"
|
Output :
a = b : true
b = c : false
c = b : false
Share your thoughts in the comments
Please Login to comment...