RE: [PHP] keeping the last zero

2004-05-17 Thread php chucker
I prefer:

round($value,2);

-Original Message-
From: Marek Kilimajer [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 17, 2004 5:10 AM
To: Mario
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] keeping the last zero

Mario wrote:
> Hi all
> 
> I have a list of products with prices
> e.g.
> 
> $100
> $100.50
> (those are examples, they can be anything, not all prices have 
> decimal)
> 
> when I add those I get $200.5.
> 
> Is there a way to get $200.50.
> 
> Thanks
> 
> Mario

You want to format the number? Use number_format()


PS: Don't hijack threads.

http://www.google.com/search?q=what+is+%22thread+hijacking%22

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] keeping the last zero

2004-05-17 Thread Marek Kilimajer
Mario wrote:
Hi all
I have a list of products with prices
e.g.
$100
$100.50
(those are examples, they can be anything, not all prices have decimal)
when I add those I get $200.5.
Is there a way to get $200.50.
Thanks
Mario
You want to format the number? Use number_format()
PS: Don't hijack threads.
http://www.google.com/search?q=what+is+%22thread+hijacking%22
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] keeping the last zero

2004-05-17 Thread Oliver Hankeln
Hi!
I have a list of products with prices
e.g.
$100
$100.50
(those are examples, they can be anything, not all prices have decimal)
when I add those I get $200.5.
Is there a way to get $200.50.
if it is okay for you to add $100+$100 and get $200.00 you could use
printf("$%1.2f",$price1+$price2);
or
$str=sprintf("$%1.2f",$price1+$price2);
HTH,
Oliver Hankeln
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] keeping the last zero

2004-05-17 Thread Mario
Hi all

I have a list of products with prices
e.g.

$100
$100.50
(those are examples, they can be anything, not all prices have decimal)

when I add those I get $200.5.

Is there a way to get $200.50.

Thanks

Mario


-
Marios Adamantopoulos
Web Developer
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php