SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: How Do You Truncate A Number?
-
May 25, 2003, 02:29 #1
- Join Date
- Dec 2002
- Location
- New Zealand
- Posts
- 1,021
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How Do You Truncate A Number?
Hi,
How do you truncate or round a number to a set no. of decimal places in PHP?
eg
16.666666666667 => 16 or 16.7
I have looked for a truncate function and a rounding funtion but can't find one.
Any help would be great,
Thanks
-
May 25, 2003, 02:37 #2
- Join Date
- Jun 2001
- Location
- Adelaide, Australia
- Posts
- 6,441
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
round(); maybe?
-
May 25, 2003, 02:41 #3
- Join Date
- Feb 2003
- Location
- Melbourne, Australia
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
... or number_format()
Counter Code Enterprise Edition
Run your own web counter/statistics service
-
May 25, 2003, 02:52 #4
- Join Date
- May 2003
- Location
- Serbia
- Posts
- 53
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
so it would be
PHP Code:echo round(16.66666667);
PHP Code:echo round(16.666667, 1);
Wondering about best weight loss pill? Take a look at Proactol.
-
May 26, 2003, 21:25 #5
- Join Date
- Dec 2002
- Location
- New Zealand
- Posts
- 1,021
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for the replies. I don't have time to look at them right now but they look like what I need.
Thanks
Bookmarks