Re: [PHP] Floating numbers truncating to two digits without rounding

2006-01-10 Thread Anas Mughal
do this all with sprintf or do I then need to convert it to a > string > > and chop off what I don't want? > > > > -Original Message- > > From: Gerry Danen [mailto:[EMAIL PROTECTED] > > Sent: Monday, January 09, 2006 3:35 PM > > To: php-general@lists.p

Re: [PHP] Floating numbers truncating to two digits without rounding

2006-01-10 Thread Gerry Danen
et > Subject: Re: [PHP] Floating numbers truncating to two digits without > rounding > > 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. &

RE: [PHP] Floating numbers truncating to two digits without rounding

2006-01-10 Thread Mark Steudel
Thanks for the info -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: Monday, January 09, 2006 3:26 PM To: php-general@lists.php.net; Mark Steudel Subject: Re: [PHP] Floating numbers truncating to two digits without rounding >I am calculating things like tax and want

Re: [PHP] Floating numbers truncating to two digits without rounding

2006-01-09 Thread Anas Mughal
Try something like: floor($value * 100)/100; -- Anas Mughal On 1/9/06, Mark Steudel <[EMAIL PROTECTED]> 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 rou

Re: [PHP] Floating numbers truncating to two digits without rounding

2006-01-09 Thread Gerry Danen
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 <[EMAIL PROTECTED]> wrote: > > I am calculating things like tax and want to format them so they only have

Re: [PHP] Floating numbers truncating to two digits without rounding

2006-01-09 Thread tedd
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. Mark: Rounding? You can try round(), such as: But, as you can see, t

Re: [PHP] Floating numbers truncating to two digits without rounding

2006-01-09 Thread Ray Hauge
On Monday 09 January 2006 03:20 pm, Mark Steudel 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 Yo

[PHP] Floating numbers truncating to two digits without rounding

2006-01-09 Thread Mark Steudel
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