1. Home
  2. Computing & Technology
  3. PHP / MySQL

Rounding and Formatting Numbers

By Angela Bradley, About.com

3 of 4

Floor () - Always Rounding Down

The Floor() PHP function is used to always round down to the nearest whole number. The PHP function Floor () behaves identical to the MySQL use; even the largest decimal will always be rounded down.
<?php
echo floor(3.14159265);
// Value would be 3

echo ceil(3.99999999);
// Value would be 3

echo ceil(-3.14159265);
// Value would be -4
?>

Index: Rounding and Formatting Numbers

  1. Round () - Rounding Numbers
  2. Ceil () - Always Rounding Up
  3. Floor () - Always Rounding Down
  4. Number_format () - Formatting your Numbers

3 of 4

Explore PHP / MySQL

More from About.com

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP Functions
  5. Floor PHP Function - PHP Floor number - Floor number function

©2008 About.com, a part of The New York Times Company.

All rights reserved.