Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
communitycreator

What is the gmp_testbit function 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_testbit is a function in PHP that tests if the specified bit of a given argument is set or not.

Syntax


gmp_testbit(GMP|int|string $num, int $index): bool

Parameters

The function takes in two parameters, num and index.

  • num can be a numeric string, GMP object, or of the int type.

  • index is the bit to test.

Return value

The function returns true if the bit at index is set. Otherwise, the function returns false.

Code

<?php
$val = gmp_init("1000000");
var_dump(gmp_testbit($n, 1));
?>

Output


bool(false)

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