Re: Floating numbers truncating to two digits without rounding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark,

Why not use sprintf() with an arbitrary large number of decimals and then
discard all but the 2 you want. I.e., format with 10 decimals and then drop
the last 8.

On 1/9/06, Mark Steudel <mark@xxxxxxxxxxxx> wrote:
>
> I am calculating things like tax and want to format them so they only have
> 2
> digits past the decimal point. I've been using sprintf but just noticed
> that
> it tends to round up. I want the same functionlity without rounding.
>
> Thanks
>
>


--
Gerry
http://portal.danen.org/

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux