Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
communitycreator

What is gmp_root 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_root is a function in PHP that returns the integer part of the nth root.

Syntax

gmp_root(GMP|int|string $num, int $Nth): GMP

Parameters

The function takes in two parameters: num and Nth.

  • num - can be a numeric string, GMPGNU Multiple Precision Arithmetic Library object, or of type int.

  • Nth - The positive root to take of num.

Return value

gmp_root returns the integer part of the Nth root. The value returned is type GMP number.

Code

<?php
// gmp_init is used to create a GMP number
$val1 = gmp_init("1001", 2);
$num = 3;
$val2 = gmp_root($val1, $num);
echo gmp_strval($val2, 2);
?>

Expected output

10

RELATED TAGS

php
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