User Tools

Site Tools


uphp:functions:number_format

number_format

WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0

Return the string value of a number formatted to a particular precision

Description

string number_format ( mixed $number, int $digits )

Parameters

$number: A number

$digits: An integer specifying the precision after the decimal point. Use 0 to truncate to a whole number.

Return Values

String value formatted at the specified precision

Example

Convert the float 1.55 into an string with a precision of 1 decimal point

<?
  $f=1.55;
  $i=number_format($f,1);
  print("The value of ".$f." is ".$i);
?>

The above example will output:

The value of 1.550000 is 1.5

See Also

floatval() - Return the float value of a number or string

strval() - Return the string equivalent of a number

is_numeric() - Check if a value is numeric (int, float or numeric string)

ieee754toint() - Convert a float value to an IEEE-754 encoded integer (32 bit)

uPHP Variable Types and Limits

uphp/functions/number_format.txt · Last modified: 2021/09/13 05:57 (external edit)