rossriley / php-scalar-objects

Experimental API for PHP Scalar Objects
70 stars 6 forks source link

Float.toPrecision/toFixed #2

Open eborden opened 10 years ago

eborden commented 10 years ago

Float.toPrecision(int) int -> string

$f = 5.123456;
$f.toPrecision(); //"5.123456"
$f.toPrecision(5); //"5.1235"
$f.toPrecision(2); //"5.1"
$f.toPrecision(1); //"5"

Float.toFixed(int) int -> string

$f = 5.123456;
$f.toFixed(); //"5.123456"
$f.toFixed(1); //"5.1"
$f.toFixed(2); //"5.12"
$f.toFixed(3); //"5.123"
$f.toFixed(10); //"5.1234560000"