array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.gmp-sqrtrem.php', 1 => 'gmp_sqrtrem', ), 'up' => array ( 0 => 'ref.gmp.php', 1 => 'GMP 関数', ), 'prev' => array ( 0 => 'function.gmp-sqrt.php', 1 => 'gmp_sqrt', ), 'next' => array ( 0 => 'function.gmp-strval.php', 1 => 'gmp_strval', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/gmp/functions/gmp-sqrtrem.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
gmp_sqrtrem — 余りつきの平方根
最初の要素が num
の整数平方根
(gmp_sqrt()も参照ください)、2 番目の要素が余り
(すなわち、num
と最初の要素の 2 乗の差)
であるような配列を返します。
例1 gmp_sqrtrem() の例
<?php
list($sqrt1, $sqrt1rem) = gmp_sqrtrem("9");
list($sqrt2, $sqrt2rem) = gmp_sqrtrem("7");
list($sqrt3, $sqrt3rem) = gmp_sqrtrem("1048576");
echo gmp_strval($sqrt1) . ", " . gmp_strval($sqrt1rem) . "\n";
echo gmp_strval($sqrt2) . ", " . gmp_strval($sqrt2rem) . "\n";
echo gmp_strval($sqrt3) . ", " . gmp_strval($sqrt3rem) . "\n";
?>
上の例の出力は以下となります。
3, 0 2, 3 1024, 0