Last active
November 3, 2021 10:49
-
-
Save mahammad/643008c838c1bbc0137d84c0418a98ff to your computer and use it in GitHub Desktop.
PHP'de sayı yuvarlama fonksiyonu
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 | |
if (!function_exists('round_up')) { | |
/** | |
* @param float $value | |
* @param integer $places | |
* @return float | |
*/ | |
function round_up($value, $places=0) | |
{ | |
if ($places < 0) { $places = 0; } | |
$mult = pow(10, $places); | |
return ceil($value * $mult) / $mult; | |
} | |
} | |
if (!function_exists('round_out')) { | |
/** | |
* @param float $value | |
* @param integer $places | |
* @return float | |
*/ | |
function round_out($value, $places=0) | |
{ | |
if ($places < 0) { $places = 0; } | |
$mult = pow(10, $places); | |
return ($value >= 0 ? ceil($value * $mult):floor($value * $mult)) / $mult; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment