mirror of
https://github.com/php/php-src.git
synced 2026-04-13 11:02:55 +02:00
`bcdiv()` and `bcmod()` throw DivisionByZeroError if the divisor is 0, which matches the behavior of the `/` and `%` operators, and `bcsqrt()` throws ValueError for negative operands.
18 lines
346 B
PHP
18 lines
346 B
PHP
--TEST--
|
|
bcsqrt — Get the square root of an arbitrary precision number
|
|
--CREDITS--
|
|
Antoni Torrents
|
|
antoni@solucionsinternet.com
|
|
--SKIPIF--
|
|
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
|
--FILE--
|
|
<?php
|
|
try {
|
|
bcsqrt('-9');
|
|
} catch (ValueError $ex) {
|
|
echo $ex->getMessage(), PHP_EOL;
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
Square root of negative number
|