Ruby | Numeric magnitude() function Improve Improve Like Article Like Save Share Report 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 # Ruby program for magnitude() method in Numeric # Initialize a number num = -19 # Prints magnitude of num puts num.magnitude() Output: 19 Example 2: Ruby # Ruby program for magnitude() method in Numeric # Initialize a number num = 100 # Prints magnitude of num puts num.magnitude() Output: 100 Last Updated : 19 Mar, 2024 Like Article Save Article Previous Ruby | Numeric denominator() function Next Ruby | Numeric abs() function Share your thoughts in the comments Add Your Comment Please Login to comment...