您的位置:首页 > 编程语言 > PHP开发

php -- 数学函数

2014-05-24 21:12 211 查看
----- 016-math.php -----

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>数学函数测试</title>
</head>
<body>
<h3>数学函数测试</h3>
<pre>
<?php
echo "-2.7的绝对值:", abs(-2.7), "\n";
echo "2.4取FLOOR:", floor(2.4), "\n";
echo "2.4取ROUND:", round(2.4), "\n";
echo "2.4取CEIL:", ceil(2.4), "\n";
echo "1023换二进制:", decbin(1023), "\n";
echo "1和0.9哪个大:", max(1, 0.9), "\n";
echo "2的30次方:", pow(2, 30), "\n";
echo "1到2随机数10次:\n";
for($i=0; $i<10; $i++)
echo rand(1, 2), "\t\n";
echo "取2的开方:", sqrt(2), "\n";
?>
</pre>
</body>
</html>


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: