Home > Backend Development > PHP Tutorial > PHP data operation examples of rounding, rounding and rounding

PHP data operation examples of rounding, rounding and rounding

WBOY
Release: 2016-07-25 09:04:34
Original
1132 people have browsed it
  1. echo round(3.4); // 3
  2. echo round(3.5); // 4
  3. echo round(3.6); // 4
  4. echo round(3.6, 0); // 4
  5. echo round(1.95583, 2); // 1.96
  6. echo round(1241757, -3); // 1242000
  7. echo round(5.045, 2); // 5.04
  8. echo round(5.055, 2); // 5.06
  9. ?>
Copy code

2. ceil() further rounding method

  1. echo ceil(4.3); // 5
  2. echo ceil(9.999); // 10
  3. ?>
Copy code

3. Floor() rounding method Rounding method

  1. echo floor(4.3); // 4
  2. echo floor(9.999); // 9
  3. ?>
Copy code


source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template