Page 1 of 1

Function that returns shorter number?

Posted: Sun Jan 01, 2006 12:47 am
by IAD
Hey,

i can't remmeber the functiopn that make numbers shorter, for example: 0.55453212 will be 0.55


Happy new year, Tal.

Posted: Sun Jan 01, 2006 3:40 am
by mickd
Round is capable for what your asking.

Posted: Sun Jan 01, 2006 4:01 am
by IAD
Not exactly, round makes number like 1.9 to 2, what i wanted is to turn number like: 0.45812 to 0.458, and then i got remember at "substr();"

Code: Select all

<?Php
  $num = "1.3334";

        print substr($num,0,5); // will return 1.333
?>

Tal

Posted: Sun Jan 01, 2006 6:21 am
by mickd
ah, so you dont want the numbers to be rounded up/down. my mistake.