<?php /* Prototype : float expm1 ( float $arg ) * Description: Returns exp(number) - 1, computed in a way that is accurate even * when the value of number is close to zero. * Source code: ext/standard/math.c */ echo "*** Testing expm1() : basic functionality ***\n"; $values = array(10, 10.3, 3950.5, 037, 0x5f, "10", "3950.5", "3.9505e3", "039", "0x5F", true, false, null); // loop through each element of $values to check the behaviour of expm1() $iterator = 1; foreach ($values as $value) { echo "\n-- Iteration {$iterator} --\n"; var_dump(expm1($value)); $iterator++; } ?> ===Done===
echo cos(-2354) . " " . cos("foo") . " " . cos(0) . " " . cos(5) . cos(1.2345) . "\n"; echo "cosh\n"; echo cosh(-2354) . " " . cosh("foo") . " " . cosh(0) . " " . cosh(5) . cosh(1.2345) . "\n"; echo "decbin\n"; echo decbin(2354) . " " . decbin("foo") . " " . decbin(0) . " " . decbin("5") . decbin(1.2345) . "\n"; echo "dechex\n"; echo dechex("2354") . " " . dechex("foo") . " " . dechex(0) . " " . dechex(5) . dechex(1.2345) . "\n"; echo "decoct\n"; echo decoct(2354) . " " . decoct("foo") . " " . decoct(0) . " " . decoct(5) . decoct(1.2345) . "\n"; echo "deg2rad\n"; echo deg2rad(-2354) . " " . deg2rad("foo") . " " . deg2rad(0) . " " . deg2rad(5) . deg2rad(1.2345) . "\n"; echo "exp\n"; echo exp(-2354) . " " . exp("foo") . " " . exp(0) . " " . exp(5) . exp(1.2345) . "\n"; if (PHP_OS != 'WINNT') { echo "expm1\n"; echo expm1(-2354) . " " . expm1("foo") . " " . expm1(0) . " " . expm1(5) . expm1(1.2345) . "\n"; } echo "floor\n"; echo floor(-2354) . " " . floor("foo") . " " . floor(0) . " " . floor(5) . floor(1.2345) . "\n"; // in windows, php has this at 32767 for no good reason if (PHP_OS != 'WINNT') { echo getrandmax() . "\n"; if (100000 < getrandmax()) { echo "getrandmax: Well, that's a start.\n"; } else { echo "woops, getrandmax: " . getrandmax() . "\n"; } } echo "hexdec\n"; echo hexdec("-2354") . " " . hexdec("foo") . " " . hexdec(0) . " " . hexdec(5) . hexdec("1.2345") . "\n"; if (PHP_OS != 'WINNT') {
/** * This method returns "e" raised to the power of this object's value minus by one. * * @access public * @static * @param IReal\Type $x the operand * @return IDouble\Type the result */ public static function expm1(IReal\Type $x) : IDouble\Type { return IDouble\Type::box(expm1($x->unbox())); }
/** * @param float $x A number * @return float The power of the Euler's constant with the given value minus 1 (e^x - 1) */ public function expm1($x) { return expm1($x); }
/** * @return $this * @desc 返回 Ex - 1 的值。 */ public function expm1() { $this->current = expm1($this->toDouble()); return $this; }
* when the value of number is close to zero. * Source code: ext/standard/math.c */ echo "*** Testing expm1() : usage variations ***\n"; //get an unset variable $unset_var = 10; unset($unset_var); // heredoc string $heredoc = <<<EOT abc xyz EOT; // get a class class classA { } // get a resource variable $fp = fopen(__FILE__, "r"); // unexpected values to be passed to $arg argument $inputs = array(0, 1, 12345, -2345, 10.5, -10.5, 123456.789, 0.00123456789, 0.5, NULL, null, true, false, TRUE, FALSE, "", '', array(), "abcxyz", 'abcxyz', $heredoc, array(), array(1, 2, 4), new classA(), @$undefined_var, @$unset_var, $fp); // loop through each element of $inputs to check the behaviour of expm1() $iterator = 1; foreach ($inputs as $input) { echo "\n-- Iteration {$iterator} --\n"; var_dump(expm1($input)); $iterator++; } fclose($fp); ?> ===Done===
<?php /* Prototype : float expm1 ( float $arg ) * Description: Returns exp(number) - 1, computed in a way that is accurate even * when the value of number is close to zero. * Source code: ext/standard/math.c */ echo "*** Testing expm1() : error conditions ***\n"; echo "\n-- Testing expm1() function with less than expected no. of arguments --\n"; expm1(); echo "\n-- Testing expm1() function with more than expected no. of arguments --\n"; expm1(23, true); ?> ===Done===
var_dump(hexdec("that")); var_dump(hexdec("a0")); var_dump(octdec("77")); var_dump(octdec(decoct(45))); var_dump(base_convert("A37334", 16, 2)); VC(pow(2, 8), 256); VC(pow(-1, 20), 1); var_dump(pow(0, 0)); var_dump(is_int(pow(2, 32))); VC(pow("2", "8"), 256); VC(pow("-1", "20"), 1); var_dump(pow("0", "0")); var_dump(is_int(pow("2", "32"))); VC(exp(12), 162754.791419); VC(exp(5.7), 298.86740096706); VC(expm1(5.7), 297.8674); var_dump(log10(10)); var_dump(log10(100)); VC(log1p(9), 2.302585092994); VC(log1p(99), 4.6051701859881); VC(log(8), 2.0794415416798); var_dump(log(8, 2)); VC(cos(M_PI), -1); VC(cosh(1.23), 1.8567610569853); VC(sin(deg2rad(90)), 1); VC(sinh(1.23), 1.5644684793044); VC(tan(deg2rad(45)), 1); VC(tanh(1.23), 0.84257932565893); VC(acos(-1), M_PI); VC(acosh(1.8567610569853), 1.23); VC(asin(1), deg2rad(90));
<?php define("MAX_64Bit", 9223372036854775807); define("MAX_32Bit", 2147483647); define("MIN_64Bit", -9223372036854775807 - 1); define("MIN_32Bit", -2147483647 - 1); $longVals = array(MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, MAX_32Bit * 2 + 1, MAX_32Bit * 2 - 1, MAX_64Bit - 1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1); foreach ($longVals as $longVal) { echo "--- testing: {$longVal} ---\n"; var_dump(expm1($longVal)); } ?> ===DONE===