Ruby | Numeric abs() function
The abs is an inbuilt method in Ruby returns the absolute value of a number.
Syntax: num.abs
Parameters: The function needs the number whose absolute value is to be returned.
Return Value: It returns the absolute value of a numbers.
Example 1:
# Ruby program for abs() method in Matrix # Initialize two numbers num = -19 # Prints absolute value of num puts num.abs() |
chevron_right
filter_none
Output:
19
Example 2:
# Ruby program for abs() method in Matrix # Initialize two numbers num = 100 # Prints absolute value of num puts num.abs() |
chevron_right
filter_none
Output:
100
Recommended Posts:
- Ruby | Numeric eql?() function
- Ruby | Numeric dup() function
- Ruby | Numeric i() function
- Ruby | Numeric quo() function
- Ruby | Numeric arg() function
- Ruby | Numeric zero? function
- Ruby | Numeric div() function
- Ruby | Numeric fdiv() function
- Ruby | Numeric imaginary() function
- Ruby | Numeric rect() function
- Ruby | Numeric ceil() function
- Ruby | Numeric infinite? function
- Ruby | Numeric real? function
- Ruby | Numeric numerator() function
- Ruby | Numeric nonzero? function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



