Ruby | Numeric magnitude() function
Last Updated :
19 Mar, 2024
The magnitude() is an inbuilt method in Ruby returns the magnitude of a number.
Syntax: num.magnitude
Parameters: The function needs the number whose magnitude is to be returned.
Return Value: It returns the magnitude of a number.
Example 1:
Ruby
num = - 19
puts num.magnitude()
|
Output:
19
Example 2:
Ruby
num = 100
puts num.magnitude()
|
Output:
100
Share your thoughts in the comments
Please Login to comment...