|
-
Jun 19th, 2002, 04:59 PM
#1
Thread Starter
Hyperactive Member
Change number format
How can I change number format?
I want to change number 3.4893 to 2 dight only until become 3.49
-
Jun 19th, 2002, 05:12 PM
#2
PowerPoster
if you're printing it:
PHP Code:
printf("%.2f", $number);
if you're just using it internally for calculations...
PHP Code:
sprintf("%.2f", $number);
or check out the number_format function
-
Jul 1st, 2002, 08:49 PM
#3
Member
If you are using it for a MySQL query, use FORMAT():
FORMAT(X,D)
Formats the number X to a format like '#,###,###.##', rounded to D decimals. If D is 0, the result will have no decimal point or fractional part:
mysql> SELECT FORMAT(12332.123456, 4);
-> '12,332.1235'
mysql> SELECT FORMAT(12332.1,4);
-> '12,332.1000'
mysql> SELECT FORMAT(12332.2,0);
-> '12,332'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|