GMP_PERFECT_SQUARE(3) 1 GMP_PERFECT_SQUARE(3)
gmp_perfect_square - Perfect square check
SYNOPSIS
bool gmp_perfect_square (GMP $a)
DESCRIPTION
Check if a number is a perfect square.
PARAMETERS
o $a
- The number being checked as a perfect square. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and
later, or a numeric string provided that it is possible to convert the latter to a number.
RETURN VALUES
Returns TRUE if $a is a perfect square, FALSE otherwise.
EXAMPLES
Example #1
gmp_perfect_square(3) example
<?php
// 3 * 3, perfect square
var_dump(gmp_perfect_square("9"));
// not a perfect square
var_dump(gmp_perfect_square("7"));
// 1234567890 * 1234567890, perfect square
var_dump(gmp_perfect_square("1524157875019052100"));
?>
The above example will output:
bool(true)
bool(false)
bool(true)
SEE ALSO
gmp_sqrt(3), gmp_sqrtrem(3).
PHP Documentation Group GMP_PERFECT_SQUARE(3)