Change language

PHP Gmp_cmp () function

|
Syntax:
gmp_cmp ($num1, $num2)
Parameters:this function accepts two GMP numbers $num1 and $num2 as required parameters, as shown in the above comparison syntax. These parameters can be GMP object in PHP 5.6 and later, or we are also allowed to pass in numeric strings so that we can convert those strings to numbers.Return value:function returns "1" if $num1 > $num2, "0" if $num1 is equal to $num2, "-1" if $num1 < $num2.Examples:
Input: gmp_cmp ("1234" , "1236") Output: -1 Input: gmp_cmp ("3569", "3569") Output: 0
The following programs illustrate the gmp_cmp() function in PHP:Program 1:A program to compare two GMP numbers when transmitted as numeric strings.
// PHP program to compare two
// GMP numbers are passed as arguments 
// lines as GMP numbers $num1 = " 12356 " ; $num2 = "12356" ;  
// compares two numbers and
// results in & quot; 0 & quot; because both are equal $res = gmp_cmp ( $num1 , $num2 ); echo $res ;  
?>
Output:
0
Program 2:A program to compare two GMP numbers when passed as GMP numbers as arguments.  
// PHP program for comparing two
// GMP numbers are passed as arguments 
// generate GMP numbers using gmp_init() $num1 = gmp_init (12355); $num2 = gmp_init (12356);  
// compares these two numbers and // produces the result & quot; -1 & quot; like $num1 < $num2 $res = gmp_cmp ( $num1 , $num2 ); echo $res ; ?>
Output:
-1
Link:
http : //php.net/manual/en/function.gmp-cmp.php

PHP Gmp_cmp () function cmp: Questions

PHP Gmp_cmp () function PHP: Questions

Shop

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method