Last active
September 9, 2016 12:01
-
-
Save Trshant/f711f18decf5cc38dabe2b4170952688 to your computer and use it in GitHub Desktop.
This gives the number rounded off the next biggest integer. Please see beneath the definition to see what i mean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function RoundingToNextTop( $num , $rounding ) { | |
return ( round( $num , (-1 * $rounding ) ) < $num )? round( $num , (-1 * $rounding ))+pow ( 10 , $rounding ) : round( $num , (-1 * $rounding ) ) ; | |
} | |
echo RoundingToNextTop( 13.3583 , 1 ) ; | |
// 20 | |
echo RoundingToNextTop( 103.3583 , 1 ) ; | |
// 110 | |
echo RoundingToNextTop( 103.3583 , 2 ) ; | |
// 200 | |
echo RoundingToNextTop( 130.3583 , 2 ) ; | |
// 200 | |
echo RoundingToNextTop( 1030.3583 , 2 ) ; | |
// 1100 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment