Ruby | Numeric to_int() function
Last Updated :
19 Mar, 2024
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:
num1 = 15 . 778
puts num1.to_int()
|
Output:
15
Example 2:
num1 = - 19 . 86
puts num1.to_int()
|
Output:
-19
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...