You are here: Re: Format float « PHP Programming Language « IT news, forums, messages
Re: Format float

Posted by Jerry Stuckle on 05/14/06 23:00

WJ Zeeuwen wrote:
> Hi all,
>
> Is it possible to adjust the number of digits in a float?
>
> For example $test = 1/3; echo ($test); gives 0.33333333.. But i only
> want 0.33
> Is there a function or do i have to use round($test*100)/100
>
> Thanx,
> WJ

If all you want to do is display the value 0.33 without actually changing the
number (which will affect future math operations), you can use

printf("%01.2f", 0.33);

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация