1. Perl
  2. builtin functions
  3. here

abs function - find absolute value

Use the abs function to find the absolute value .

abs $num;

The absolute value is a size that does not consider the sign, and is always a positive value. It is a number that represents how far away from 0. If it is "3", it will be "3", and if it is "-3", it will be "3".

Example

This is an example to find the absolute value.

use strict;
use warnings;

my $num = -4;
my $num2 = abs $num;
print "(1) Find the absolute value.\n";
print "$num2\n";

Related Informatrion