User Tools

Site Tools


uphp:functions:number_format

This is an old revision of the document!


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 $value, int $precision )

Return the string value formatted at the specified precision

Parameters

$value: A number

$precision: An int specifying the precision after the decimal point. Use 0 to round to a whole number.

Return Value

String value

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 integer value of ".$f." is ".$i);
?>

The above example will output:

The integer 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.1494493026.txt.gz · Last modified: 2021/09/13 05:56 (external edit)