Ruby | Numeric to_int() function Last Updated : 19 Mar, 2024 Comments Improve Suggest changes Like Article Like Report The to_int() is an inbuilt method in Ruby returns the integer part of the given number. Syntax: num.to_int() Parameters: The function needs the number whose integer part is to be returned. Return Value: It returns the integer part. Example 1: Ruby # Ruby program for to_int() # method in Numeric # Initialize a number num1 = 15.778 # Prints the integer part puts num1.to_int() Output: 15 Example 2: Ruby # Ruby program for to_int() # method in Numeric # Initialize a number num1 = -19.86 # Prints the integer part puts num1.to_int() Output: -19 Comment More infoAdvertise with us Next Article Ruby | Numeric to_int() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Numeric-class Similar Reads Ruby | Numeric i() function The i() is an inbuilt method in Ruby returns a complex number with the imaginary part that is given. Syntax: num.i() Parameters: The function needs a number which is the imaginary part of the complex number. Return Value: It returns a complex number with the imaginary part. Example 1: CPP # Ruby pro 1 min read Ruby | Numeric to_c() function The to_c() is an inbuilt method in Ruby returns a complex number with the num. Syntax: num.to_c() Parameters: The function needs the number which is to be returned as complex. Return Value: It returns the complex number. Example 1: Ruby # Ruby program for to_c() # method in Numeric # Initialize a nu 1 min read Ruby | Numeric integer() function The integer?() is an inbuilt method in Ruby returns a boolean value. It returns true if the number is an integer one, else it returns false. Syntax: num.integer?() Parameters: The function needs a number which is to be checked for. Return Value: It returns returns a boolean value. Example 1: CPP # R 1 min read Ruby | Numeric infinite? function The infinite?() is an inbuilt method in Ruby returns nil if the number is finite. It returns -1 and +1 if the number is -infinity or +infinity. Syntax: num.infinite?() Parameters: The function needs a number which is to be checked. Return Value: It returns nil, -1 or +1. Example 1: Ruby # Ruby progr 1 min read Ruby | Numeric imag() function The imag() is an inbuilt method in Ruby returns the imag part of the given number. Syntax: num.imag() Parameters: The function needs a number whose imag part is to be returned. Return Value: It returns the imag part. Example 1: CPP # Ruby program for imag() # method in Numeric # Initialize a number 1 min read Like