Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
gmp_divexact
communitycreator

What is gmp_divexact in PHP?

Hammad Nasir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

gmp_divexact is a function in PHP that computes the exact division of numbers.

Syntax


gmp_divexact(GMP|int|string $number1, GMP|int|string $number2): GMP

Parameters

  • number1: The number that is going to be divided.

  • number2: The number that number1 is being divided by.


number1 and number2 can be a GMP object, an integer, or a numeric string.


Return value

The function returns the result of the division. The value returned is a GMP number type.


This function only returns correct results when it is known in advance that number2 divides number1.

Code

<?php
// numeric strings passed as arguments
$num1 = "15";
$num2 = "3";
$result = gmp_divexact($num1, $num2);
echo $result;
// result of this example will not be correct
$val1 = "10";
$val2 = "3";
$result1 = gmp_divexact($val1, $val2);
echo $result1;
?>

Output


5
2863311534

RELATED TAGS

php
gmp_divexact
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring