SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP Math

Getting the higher and lower hundred value using ceil and floor function in PHP

IN an umber we can find out the next higher integer using ceil function. This function is different than round function. In case of round function the value is rounded to higher or lower value, but here it is always higher value is returned. Here is an example
$v = ceil(6.25);
// which would make $v=7
This function is useful when we search for a next higher hundred or thousand value of a number. For example we have a number 785 and wants to know what is the next higher hundredth number ( that is 800 ). To know this we can use ceil function. If you are generating a graph and coordinates are fixed according to high and low value of the data then using this function we can find out what should be our highest point in the graph.
$v=485;
$base_m=100;
$v_max=$base_m*(ceil($v/$base_m));
//$v_max equal to 500
Same way we can find out the lowest value of a figure using floor function in php
$v=485;
$base_m=100;
$v_min=$base_m*(floor($v/$base_m));
//$v_min equal to 400
Note that there is no point is using ceil and floor functions on integers directly. ( we will get the same value )

Be the first to post comment on this article :


Google+

Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer