Ruby Integer abs() function with example Last Updated : 09 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The abs() function in Ruby returns the absolute value of the integer. Syntax: (number).abs Parameter: The function takes the integer whose absolute value is to be returned. Return Value: The function returns the absolute value of the integer. Example #1: Ruby # Ruby program Integer abs() function # Initializing the numbers num1 = -21 num2 = 21 num3 = 0 num4 = -100 # Printing the absolute value of integers puts (num1).abs puts (num2).abs puts (num3).abs puts (num4).abs Output : 21 21 0 100 Example #2: Ruby # Ruby program of Integer abs() function # Initializing the numbers num1 =29 num2 = -7 num3 = 90 num4 = -10 # Printing the absolute value of integers puts (num1).abs puts (num2).abs puts (num3).abs puts (num4).abs Output: 29 7 90 10 Comment More infoAdvertise with us Next Article Ruby Integer abs() function with example G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby Integer div() function with example The div() function in Ruby returns the integer division of two numbers. Syntax: (number1).div(number2) Parameter: The function needs two numbers number1 and number2, where number1 is the dividend and number2 is the divisor. Return Value: The function returns the integer division of two numbers. Exam 1 min read Ruby Integer even? function with example The even? function in Ruby returns a boolean value. It returns true if the number is even, else it returns false. Syntax: number.even? Parameter: The function takes the integer which is to be checked for even or not. Return Value: The function returns a boolean value which determines if the value is 1 min read Ruby Integer downto() function with example The downto() function in Ruby returns all the numbers less than equal to number and greater than equal to limit. It iterates the given block, passing in decreasing values from int down to and including limit. If no block is given, an Enumerator is returned instead. Syntax: (number).downto(limit) Par 2 min read Ruby Integer odd? function with example The odd? function in Ruby returns a boolean value. It returns true if the number is odd, else it returns false. Syntax: number.odd? Parameter: The function takes the integer which is to be checked for odd or not. Return Value: The function returns a boolean value which determines if the value is odd 1 min read Ruby Integer pred() function with example The pred function in Ruby returns the immediate predecessor of the number, i.e., it returns number - 1. If a float value is used, it throws an error message. Syntax: number.pred Parameter: The function takes the integer whose predecessor is to be returned. Return Value: The function returns the imme 1 min read Like