X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FNumber.php;h=02e31ad96a5790c7167dcf24829eb911d1036b6a;hb=ead0c08f09f10fc2b62a655c08bbe69a1249f55c;hp=26a3bf79a216fc2e9b3651b79d4b906c1496acb0;hpb=4e2d3adb5cbcb9f48e4638e4e755f95faffc3d99;p=civicrm-core.git diff --git a/CRM/Utils/Number.php b/CRM/Utils/Number.php index 26a3bf79a2..02e31ad96a 100644 --- a/CRM/Utils/Number.php +++ b/CRM/Utils/Number.php @@ -34,6 +34,7 @@ * Class CRM_Utils_Number */ class CRM_Utils_Number { + /** * Create a random number with a given precision. * @@ -64,13 +65,16 @@ class CRM_Utils_Number { public static function createTruncatedDecimal($keyValue, $precision) { list ($sigFigs, $decFigs) = $precision; $sign = ($keyValue < 0) ? '-1' : 1; - $val = str_replace('.', '', abs($keyValue)); // ex: -123.456 ==> 123456 - $val = substr($val, 0, $sigFigs); // ex: 123456 => 1234 + // ex: -123.456 ==> 123456 + $val = str_replace('.', '', abs($keyValue)); + // ex: 123456 => 1234 + $val = substr($val, 0, $sigFigs); // Move any extra digits after decimal $extraFigs = strlen($val) - ($sigFigs - $decFigs); if ($extraFigs > 0) { - return $sign * $val / pow(10, $extraFigs); // ex: 1234 => 1.234 + // ex: 1234 => 1.234 + return $sign * $val / pow(10, $extraFigs); } else { return $sign * $val; @@ -109,7 +113,7 @@ class CRM_Utils_Number { // respect php.ini upload_max_filesize if ($size > $maxImportFileSize && $size !== $postMaxSize) { $size = $maxImportFileSize; - CRM_Core_Session::setStatus(ts("Note: Please verify your configuration for Maximum File Size (in MB) Administrator >> System Settings >> Misc. It should support 'upload_max_size' as defined in PHP.ini.Please check with your system administrator.", array(1 => CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1'))), ts("Warning"), "alert"); + CRM_Core_Session::setStatus(ts("Note: Please verify your configuration for Maximum File Size (in MB) Administrator >> System Settings >> Misc. It should support 'upload_max_size' as defined in PHP.ini.Please check with your system administrator.", [1 => CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1')]), ts("Warning"), "alert"); } } return $size;