ceil是向上进位得到一个值的函数; floor是舍掉小数位得到一个值的函数; round是用来四舍五入的函数。 ceil 定义和用法: ceil() 函数向上舍入为最接近的整数。 [php] ceil(x); ceil(x); 说明: 返回不小于 x 的下一个整数,x 如果有小数部分则进一位。 ceil(
ceil是向上进位得到一个值的函数;
floor是舍掉小数位得到一个值的函数;
round是用来四舍五入的函数。
ceil
定义和用法:
ceil() 函数向上舍入为最接近的整数。
[php]
ceil(x);
ceil(x);
说明:
返回不小于 x 的下一个整数,x 如果有小数部分则进一位。
ceil() 返回的类型仍然是 float。
例子:
[php]
echo ceil(0.60);
echo "
echo ceil(0.40);
echo "
echo ceil(5);
echo "
echo ceil(5.1);
echo "
echo ceil(-5.1);
echo "
echo ceil(-5.9);
?>
echo ceil(0.60);
echo "
echo ceil(0.40);
echo "
echo ceil(5);
echo "
echo ceil(5.1);
echo "
echo ceil(-5.1);
echo "
echo ceil(-5.9);
?>
输出:
[php]
1
1
5
6
-5
-5
1
1
5
6
-5
-5
floor
定义和用法:
floor() 函数向下舍入为最接近的整数。
[php]
floor(x);
floor(x);
说明:
返回不大于 x 的下一个整数,将 x 的小数部分舍去取整。
floor() 返回的类型仍然是 float。
例子:
[php]
echo(floor(0.60));
echo "
";
echo(floor(0.40));
echo "
";
echo(floor(5));
echo "
";
echo "
";
echo(floor(5.1));
echo "
";
echo(floor(-5.1));
echo "
";
echo(floor(-5.9))
?>
echo(floor(0.60));
echo "
";
echo(floor(0.40));
echo "
";
echo(floor(5));
echo "
";
echo "
";
echo(floor(5.1));
echo "
";
echo(floor(-5.1));
echo "
";
echo(floor(-5.9))
?>
输出:
[php]
0
0
5
5
-6
-6
0
0
5
5
-6
-6
round
定义和用法
round() 函数对浮点数进行四舍五入。
[php]
round(x,prec);
round(x,prec);
其中
x(可选) 规定要舍入的数字。
prec(可选) 规定小数点后的位数。
说明:
返回将 x 根据指定精度 prec (十进制小数点后数字的数目)进行四舍五入的结果。
prec 也可以是负数或零(默认值)。
例子:
[php]
echo round(12.345,-1);
echo "
echo round(12.345);
echo "
echo round(0.5);
echo "
echo round(0.4);
echo "
echo round(-0.5);
echo "
echo round(-0.4);
?>
echo round(12.345,-1);
echo "
echo round(12.345);
echo "
echo round(0.5);
echo "
echo round(0.4);
echo "
echo round(-0.5);
echo "
echo round(-0.4);
?>
输出:
[php]
10
12
1
0
-1
-0

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Atom editor mac version download
The most popular open source editor
