Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

abs

Returns the absolute value of its argument.

Returns the absolute value of EXPR, or $_ if omitted. Preserves the numeric type: integers remain integers (Iv), floats remain floats (Nv).

Synopsis

my $n = abs(-42);      # 42
my $n = abs($x);
my $n = abs;           # abs($_)

See Also

int