PHP - gmp_div_q() Function
Definition and Usage
The gmp_div_q() function divide the numbers given.
Description
gmp_div_q() divides the number given and returns a GMP number.
Syntax
gmp_div_q ( GMP $a , GMP $b [, int $round = GMP_ROUND_ZERO ] ) : GMP
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
a |
| 2 |
b The number that you will divide with parameter a. It can a GMP resource number , a gmp object or a numeric string . |
| 3 |
round
The rounding is done as follows −
|
Return Values
PHP gmp_div_q() function divides the numbers given and returns GMP number.
PHP Version
This function will work from PHP Version greater than 5.0.0.
Example 1
Working of gmp_div_q −
<?php
$num1 = gmp_div_q("200", "5");
$num2 = gmp_div_q("99", "3");
$num3 = gmp_div_q("1", "3", GMP_ROUND_PLUSINF);
$num4 = gmp_div_q("-100", "4", GMP_ROUND_PLUSINF);
$num5 = gmp_div_q("-50", "4", GMP_ROUND_MINUSINF);
echo "The number 200/5 is : ".$num1;
echo "<br/><br/>";
echo "The number 99/3 is : ".$num2;
echo "<br/><br/>";
echo "The number 1/3 is : ".$num3;
echo "<br/><br/>";
echo "The number -100/4 is : ".$num4;
echo "<br/><br/>";
echo "The number -50/4 is : ".$num5;
?>
This will produce following result −
The number 200/5 is : 40 The number 99/3 is : 33 The number 1/3 is : 1 The number -100/4 is : -25 The number -50/4 is : -13
Example 2
Working of gmp_div_q with hexadecimal numbers −
<?php
$num1 = gmp_div_q("0x80", "0xFF");
echo "The number 0x80/0xFF is : ".$num1;
?>
This will produce following result −
The number 0x80/0xFF is : 0
php_function_reference.htm
Advertisements