Ruby | Float to_i() method
Last Updated :
07 Jan, 2020
Float#to_i() is a float class method which return a Integer representation of the float value.
Syntax: float.to_i()
Parameter: float value as argument
Return: Integer representation of the float value.
Example #1 :
a = 0 . 756567
b = 2797999 . 011
puts "Integer a : #{a.to_i}\n\n"
puts "Integer b : #{b.to_i}\n\n"
|
Output :
Integer a : 0
Integer b : 2797999
Example #2 :
a = 0 . 767
b = 2999 . 011
puts "Integer a : #{a.to_i}\n\n"
puts "Integer b : #{b.to_i}\n\n"
|
Output :
Integer a : 0
Integer b : 2999
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...