HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gmp_testbit

Description

The gmp_testbit of GMP for PHP tests if a bit is set.

Syntax

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

Parameters

num

A GMP object, an int or a numeric string.

index

The bit to test

Return

Returns true if the bit is set in num, otherwise false.

Examples

1 · num · GMP · index · 0

<?

$num = 0b101;
$index = 0;

$num = gmp_init($num);

$return = gmp_testbit($num, $index);

var_export($return);
true

2 · num · GMP · index · 1

<?

$num = 0b101;
$index = 1;

$num = gmp_init($num);

$return = gmp_testbit($num, $index);

var_export($return);
false

3 · num · int · index · 0

<?

$num = 0b101;
$index = 0;

$return = gmp_testbit($num, $index);

var_export($return);
true

4 · num · int · index · 1

<?

$num = 0b101;
$index = 1;

$return = gmp_testbit($num, $index);

var_export($return);
false

5 · num · string · index · 0

<?

$num = "0b101";
$index = 0;

$return = gmp_testbit($num, $index);

var_export($return);
true

6 · num · string · index · 1

<?

$num = "0b101";
$index = 1;

$return = gmp_testbit($num, $index);

var_export($return);
false