Ruby | Float to_i() method Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report 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 : Ruby # Ruby code for to_i() method # declaring float value a = 0.756567 # declaring float value b = 2797999.011 # converting to integer puts "Integer a : #{a.to_i}\n\n" # converting to integer puts "Integer b : #{b.to_i}\n\n" Output : Integer a : 0 Integer b : 2797999 Example #2 : Ruby # Ruby code for to_i() method # declaring float value a = 0.767 # declaring float value b = 2999.011 # converting to integer puts "Integer a : #{a.to_i}\n\n" # converting to integer puts "Integer b : #{b.to_i}\n\n" Output : Integer a : 0 Integer b : 2999 Comment More infoAdvertise with us Next Article Ruby | Float to_i() method M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Float-class Similar Reads 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 # Ruby code for equal() method # Declaring float value a = -100.7 1 min read Ruby Float to_r() method with example Float to_r() is a float class method which return a rational form of the float value. Syntax: float.to_r() Parameter: float value as argument Return: Rational form representation of the float value. Example #1 : Ruby # Ruby code for to_r() method # Initializing values a = 2.0 b = 9.99991 # Printing 1 min read Ruby Float zero?() method with example Float#zero() : zero() is a float class method which checks whether the float value is zero. Syntax: float.zero() Parameter:float value which is to be checked Return: Boolean value return true if value is zero otherwise return false Example #1: Ruby # Ruby code for zero?() method # Initializing value 1 min read Ruby | Float numerator() method Float numerator() is a float class method which return a float value as the numerator value for p/q form. Syntax:float.numerator() Parameter: float value (p) for the p/q form. [Always positive] Return: A machine-dependent result. Example #1: Ruby # Ruby program for numerator() method a = 2.0.numerat 1 min read Ruby Float floor() method with example floor() is a float class method which return the floor value of the passed float value. Syntax: float.floor() Parameter: float value which is to get its floor value decimal digits (default = 0) Return: smallest number >= to float with a ndigits decimal point precision. For -ve precision : Integer 1 min read Like