Skip to content

Instantly share code, notes, and snippets.

@aalfiann
Created April 6, 2018 07:36
Show Gist options
  • Save aalfiann/3da86a62c9eac79022f1575286648ee7 to your computer and use it in GitHub Desktop.
Save aalfiann/3da86a62c9eac79022f1575286648ee7 to your computer and use it in GitHub Desktop.
Round decimal value with custom nearest point number (PHP)
/**
* 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