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
Convert a file size value from the formats allowed in php_ini to the number of bytes.
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 ]) : 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
Tags
throws
UnknownCurrencyException
Return values
string

formatUnitSize()

Convert a file size value from the formats allowed in php_ini to the number of bytes.

public static formatUnitSize(string $size) : int
Parameters
$size : string
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