Created
April 6, 2018 07:36
-
-
Save aalfiann/3da86a62c9eac79022f1575286648ee7 to your computer and use it in GitHub Desktop.
Round decimal value with custom nearest point number (PHP)
This file contains 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
/** | |
* Round decimal value with custom nearest point number | |
* | |
* @param numToRound is the value number to round | |
* @param pointDecimal is the nearest point | |
* @return decimal | |
*/ | |
private function limitRound($numToRound,$pointDecimal=0.5){ | |
$value = 0; | |
if(($numToRound - floor($numToRound)) >= $pointDecimal){ | |
$value = 1; | |
} else { | |
$value = 0; | |
} | |
return floor($numToRound + $value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment