Home > Backend Development > PHP Tutorial > php 保存小数点 总结

php 保存小数点 总结

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:16:29
Original
1012 people have browsed it

php 保留小数点 总结

php保留两位小数并且四舍五入?

Php代码??收藏代码
  1. $num?=?123213.666666;??
  2. echo?sprintf("%.2f",?$num);??




php保留两位小数并且不四舍五入?

Php代码??收藏代码
  1. $num?=?123213.666666;??
  2. echo?sprintf("%.2f",substr(sprintf("%.3f",?$num),?0,?-2));??



php进一法取整?

Php代码??收藏代码
  1. echo?ceil(4.3);????//?5??
  2. echo?ceil(9.999);??//?10??



php舍去法,取整数?

Php代码??收藏代码
  1. echo?floor(4.3);???//?4??
  2. echo?floor(9.999);?//?9??
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template