Documentation

CRM_Utils_Number
in package

Class CRM_Utils_Number

Table of Contents

Methods

createRandomDecimal()  : float
Create a random number with a given precision.
createTruncatedDecimal()  : float
Given a number, coerce it to meet the precision requirement. If possible, it should keep the number as-is. If necessary, this may drop the least-significant digits and/or move the decimal place.
formatLocaleNumeric()  : string
Format number for display according to the current or supplied locale.
formatUnitSize()  : int
getMaximumFileUploadSize()  : float
Get the maximum size permitted for a file upload.

Methods

createTruncatedDecimal()

Given a number, coerce it to meet the precision requirement. If possible, it should keep the number as-is. If necessary, this may drop the least-significant digits and/or move the decimal place.

public static createTruncatedDecimal(int|float $keyValue, array<string|int, mixed> $precision) : float
Parameters
$keyValue : int|float
$precision : array<string|int, mixed>

(int $significantDigits, int $postDecimalDigits).

Tags
link
https://dev.mysql.com/doc/refman/5.1/en/fixed-point-types.html
Return values
float

formatLocaleNumeric()

Format number for display according to the current or supplied locale.

public static formatLocaleNumeric(string $amount[, string $locale = null ][, array<string|int, int> $attributes = [] ]) : string

Note this should not be used in conjunction with any calls to replaceCurrencySeparators as this function already does that.

Parameters
$amount : string
$locale : string = null
$attributes : array<string|int, int> = []

Options passed to NumberFormatter::setAttribute see https://www.php.net/manual/en/class.numberformatter.php#intl.numberformatter-constants.unumberformatattribute

Return values
string

formatUnitSize()

public static formatUnitSize(mixed $size) : int

use ini_parse_quantity

Parameters
$size : mixed
Return values
int

getMaximumFileUploadSize()

Get the maximum size permitted for a file upload.

public static getMaximumFileUploadSize() : float
Return values
float

        
On this page

Search results