PHP Programming How To Make Round Numbers from Float Numbers Rounding

Mobile
feeds
Welcome Login | Register

PHP Programming How To Make Round Numbers from Float Numbers Rounding
Reply Your Comments:
Click this button if you are interested in replying to this topic and leave your comments
Sent To Friend
CLick this button if you want to send this page to a friend.
Subsribe To Rss Feeds
Subscribe to RSS
CLick this button if you want to subscribe to this RSS Feed. You can use your browsers feeds burners if you have mozilla or internet explorer 7 or higher and keep up with updates.
  Forums Index
      » PHP Forums
        » » PHP Programming How To Make Round Numbers from Float Numbers Rounding
PHP Programming How To Make Round Numbers from Float Numbers Rounding
Post Description: php programming how to make round numbers from float numbers rounding PHP
Post Tags:
This Post Has Been Viewed 969 Times Since Mon Dec 04, 2006 9:33 pm Author bigger_travis with 0 replies
PHP Programming How To Make Round Numbers from Float Numbers Rounding
Advertise On This Page




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

Your Name
Your Email Address (Will Not Be Published)
Notify Me When Someone Replies to this Page
(An email will be sent to you when someone replies to your comments)
Your Comments
Include A Picture with your comments
Share
| More
Share this page by putting this URL in your comments to other websites like myspace, Facebook, Twitter friendster, Hi5, Groups, Boards, Forum or others. Just Copy and Paste this Code
URL:
To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it.
Embed:
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
BBCODE:
Subscribe Feeds
Webmasters - Exchange Links With Us. Add related websites to this topic
Add Link:
Links Related to : PHP Programming How To Make Round Numbers from Float Numbers Rounding

Comments and replies About PHP Programming How To Make Round Numbers from Float Numbers Rounding
(0) Comments