Absolute Value

From SwiftAPI

(Redirected from Perl abs)
Jump to: navigation, search

Contents

C

#include <stdlib.h>
 
int n = -5;
int x = abs(n);
// x == 5

Java

java.lang.Math : static double abs(double a)
java.lang.Math : static float abs(float a)
java.lang.Math : static int abs(int a)
java.lang.Math : static long abs(long a)
int n = -5;
int x = Math.abs(n);
// x == 5

JavaScript

var n = -5;
var x = Math.abs(n);
// x == 5

Perl

perldoc.perl.org

abs VALUE
$n = -5;
$x = abs($n);
# $x == 5

PHP

php.net

number abs ( mixed $number )
$n = -5;
$x = abs($n);
// $x == 5

Python

docs.python.org

abs(x)
n = -5
x = abs(n)
# x == 5

Ruby

n = -5
x = n.abs
# x == 5
Personal tools