Mateobus Posted September 11, 2006 Share Posted September 11, 2006 I want to make a number have 3 decimal places regardless of what it is. Ie$i = 7;i want 7.00 Link to comment https://forums.phpfreaks.com/topic/20337-type-cast-a-number-to-3-digit-float/ Share on other sites More sharing options...
jefkin Posted September 11, 2006 Share Posted September 11, 2006 Um, what about 37 do you want 37.00 or 37.0 ???Do you mean signifigant figures?How about .00002323 do you want .000 or do you want .0000232round()provides some functionality you might find useful.Jeff Link to comment https://forums.phpfreaks.com/topic/20337-type-cast-a-number-to-3-digit-float/#findComment-89618 Share on other sites More sharing options...
Jenk Posted September 11, 2006 Share Posted September 11, 2006 [url=http://us2.php.net/manual/en/function.number-format.php]number_format()[/url] may also be of use. Link to comment https://forums.phpfreaks.com/topic/20337-type-cast-a-number-to-3-digit-float/#findComment-89695 Share on other sites More sharing options...
°°Ben³ Posted September 11, 2006 Share Posted September 11, 2006 sprintf(), too. Link to comment https://forums.phpfreaks.com/topic/20337-type-cast-a-number-to-3-digit-float/#findComment-89757 Share on other sites More sharing options...
obsidian Posted September 11, 2006 Share Posted September 11, 2006 [quote author=Jenk link=topic=107590.msg431974#msg431974 date=1157964286][url=http://us2.php.net/manual/en/function.number-format.php]number_format()[/url] may also be of use.[/quote]that's probably your best bet since it returns a float with the exact precision you request. Link to comment https://forums.phpfreaks.com/topic/20337-type-cast-a-number-to-3-digit-float/#findComment-89765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.