PHP Programming How To Make Round Numbers From Float Numbers Rounding



PHP Programming How To Make Round Numbers From Float Numbers Rounding
PHP Programming How To Make Round Numbers From Float Numbers Rounding
Post Description:
Post Tags: php, programming, how, to, make, round, numbers, from, float, numbers, rounding
This Post Has Been Viewed 807 Times Since Mon Dec 04, 2006 9:33 pm Posted By bigger_travis with 0 replies
PHP Programming How To Make Round Numbers From Float Numbers Rounding
round() function:

round Rounds a float number

[This post sponsered by www.webune.com]
post picture

if you are a php programmer, you will often need to round numbers from float numbers. What are float numbers? floats are numbers with a decimal point. for example: 2.49 is a float, where as 2 is the rounded number. Its often useful to use the round() function in php because it makes your code run smooter, specially in non-mathematical sites.

it is supported in PHP 3, PHP 4 and PHP 5

Description
float round ( float val [, int precision] )

Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default).

here are some exaples you can use to get an idea;


     Code:
<?php
echo round(3.4); // 3
echo round(3.5); // 4
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.045, 2); // 5.05
echo round(5.055, 2); // 5.06
?>


if you need more help on this, php.net is a great site to get information about php functions. i use it all the time

you can get more info on this function on:

http://www.php.net/manual/en/function.round.php

hope this helps.

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About PHP Programming How To Make Round Numbers From Float Numbers Rounding




(0) Comments