Ruby | Numeric abs2() function Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The abs2() is an inbuilt method in Ruby returns the square of a number. Syntax: num.abs2 Parameters: The function needs the number whose square is to be returned. Return Value: It returns the square of a number. Example 1: Ruby # Ruby program for abs2() method in Numeric # Initialize a number num = -19 # Prints square of num puts num.abs2() Output: 361 Example 2: Ruby # Ruby program for abs2() method in Numeric # Initialize a number num = 100 # Prints square of num puts num.abs2() Output: 10000 Comment More infoAdvertise with us Next Article Ruby | Numeric arg() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Numeric-class Similar Reads 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 # Ruby program for abs() method in Numeric # I 1 min read Ruby | Numeric arg() function The arg() is an inbuilt method in Ruby returns 0 if the number is positive, else it returns a float value which is equal to pi. Syntax: num.arg() Parameters: The function needs a number. Return Value: It returns 0 if the number is positive, else it returns a float value which is equal to pi. . Exa 1 min read Ruby | Numeric angle() function The angle() is an inbuilt method in Ruby returns 0 if the number is positive, else it returns a float value which is equal to pi. Syntax: num.angle() Parameters: The function needs a number. Return Value: It returns 0 if the number is positive, else it returns a float value which is equal to pi. . 1 min read Ruby | Numeric eql?() function The eql?() is an inbuilt method in Ruby returns a boolean value. It returns true if both the numbers are equal, else it returns false. Syntax: num1.eql?(num2) Parameters: The function needs two number whose comparison is to be done. Return Value: It returns returns true if both are equal, else it r 1 min read Ruby | Numeric div() function The div() is an inbuilt method in Ruby that returns the result after performing an integer division. Syntax: num1.div(num2) Parameters: The function needs two numbers whose integer division is to be performed. Return Value: It returns returns the integer division.Example 1: CPP #Ruby program for div 1 min read Ruby | Numeric i() function The i() is an inbuilt method in Ruby returns a complex number with the imaginary part that is given. Syntax: num.i() Parameters: The function needs a number which is the imaginary part of the complex number. Return Value: It returns a complex number with the imaginary part. Example 1: CPP # Ruby pro 1 min read Like