PHP关于数据的舍入关键字归类:round() ceil() floor() number_format()
来源:互联网 发布:淘宝官网购物 编辑:程序博客网 时间:2024/06/06 19:23
round -- 对浮点数进行四舍五入
例子:
例子:
<?php
echo round(3.4); // 3
echo round(3.6); // 4
echo round(3.6, 0); // 4
echo round(1.95583, 2); // 1.96
echo round(1241757, - 3); // 1242000
echo round(5.055, 2); // 5.06
?>
ceil -- 进一法取整
例子:
<?php
echo ceil(4.3); // 5
echo ceil(9.999); // 10
?>
floor -- 舍去法取整,跟ceil刚刚相反
例子:
<?php
echo floor(4.3); // 4
echo floor(9.999); // 9
?>
number_format
$number = 1234;
// english notation (default)
$english_format_number = number_format($number);
echo "First:".$english_format_number."<br/>";
// French notation
$nombre_format_francais = number_format($number, 2, ',', '');
echo "Second:".$nombre_format_francais."<br/>";
// French notation
$number = 1234.564;
$nombre_format_francais = number_format($number, 2, ',', '');
echo "Third:".$nombre_format_francais."<br/>";
$number = 1234.5678;
// english notation without thousands seperator
$english_format_number = number_format($number, 2, '.', '');
echo "Forth:".$english_format_number."<br/>";
?>
显示结果最终如下:
First:1,234
Second:1234,00
Third:1234,56
Forth:1234.57
- PHP关于数据的舍入关键字归类:round() ceil() floor() number_format()
- 关于ceil、floor、round函数的用法
- javascript,小数值舍入操作方法:ceil()、floor()、round()
- ceil、floor、round的使用
- ceil() floor() round()的用法
- ceil() floor() round()的用法
- Matlab的Floor, Ceil, Fix, Round
- Math ceil(),floor(),round()方法的使用
- Java Math的floor,round,ceil使用方法
- Math 的三个函数 round ceil floor
- round、floor和ceil的使用
- Java Math的floor、ceil、round方法
- round、floor、ceil、trunc的对比
- Java Math的 floor,round和ceil
- Math中的round、ceil、floor的功能。
- ceil floor round
- Math.round ceil floor
- Round, Floor, Ceil
- 如何修改wince触摸屏校准界面 的显示文字
- Eclipse+Axis2+android构建WebService实战总结
- Kinect SDK 1.6+OpenNI 2.1+VS2010+Win7的配置
- python xmlrpc 服务端返回慢的解决方案
- cookie 无刷新
- PHP关于数据的舍入关键字归类:round() ceil() floor() number_format()
- java中如何遍历实体类的属性和数据类型以及属性值
- java中的关键字static总结
- eclipse/myeclipse的使用,持续更新中~~
- 三星4412开发板简单介绍
- 自动提示: <C-n> 和 <C-p>
- c++ primer读书笔记(四)
- 关于 PLSQL Developer
- 协议protocol相关笔记