• PHP Video Tutorials

PHP - gmp_sign() Function



Definition and Usage

The gmp_sign() function returns the sign of the given number.

Description

The gmp_sign() returns the sign of the given GMP number.

Syntax

gmp_sign ( GMP $a ) : int

Parameters

Sr.No Parameter & Description
1

a

It can a GMP resource number , a gmp object or a numeric string.

Return Values

PHP gmp_sign() function returns 1 if the gmp number is positive, -1 if negative and 0 if the number is 0.

PHP Version

This function will work from PHP Version greater than 5.0.0.

Example 1

Working of gmp_sign() −

<?php
   $sign = gmp_sign("56565");
   echo "The Sign of 56565 is :".$sign;
?>

This will produce following result −

The Sign of 56565 is :1

Example 2

Working of gmp_sign() −

<?php
   $sign = gmp_sign("-56565");
   echo "The Sign of -56565 is :".$sign;
?>

This will produce following result −

The Sign of -56565 is :-1
php_function_reference.htm
Advertisements