HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gmp_abs

Description

The gmp_abs of GMP for PHP gets the absolute value.

Syntax

gmp_abs(
    GMP|int|string $num
): GMP

Parameters

num

A GMP object, an int or a numeric string.

Return

Returns the absolute value of num, as a GMP number.

Examples

1 · num · GMP

<?

$num = -1;

$num = gmp_init($num);

$return = gmp_abs($num);

var_dump($return);
object(GMP)#2 (1) {
  ["num"]=>
  string(1) "1"
}

2 · num · int

<?

$num = -1;

$return = gmp_abs($num);

var_dump($return);
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "1"
}

3 · num · string

<?

$num = "-1";

$return = gmp_abs($num);

var_dump($return);
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "1"
}