RE: [PHP] Problem with wanting something NOT to round
| From: | George Pitcher | Date: | Fri, 17 Nov 2006 10:20:55 +0000 |
| Subject: | RE: [PHP] Problem with wanting something NOT to round | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244792@lists.php.net to get a copy of this message | ||
> George Pitcher wrote:
> > As part of a result from a web-service call, I get a price in
> dollars and
> > cents as a decimal number eg.160.44 (the example I am working on. This
> > price is for permission to re-use some published material and for each
> > additional separate pagerange, $3 needs to be added afterwards.
> >
> > So I have the following code in my script:
> >
> > $range = explode(",",$pr);
> > $rangecounter = count($range);
> > $rangecounter = ($rangecounter>1?$rangecounter-1:0);
> > $ccc_supp = floatval($rangecounter * 3);
> > $fee2 = floatval($fee + $ccc_supp);
> > echo sprintf("%01.2f",$fee2);
> >
> > $pr is my pagerange which, in this case is 9-24, generates a
> rangecounter of
> > 1, so does not get any additional $3 added.
> >
> > My echo produces 160, instead of the 160.44 which I want.
> >
> > Can anyone point me in the direction of a solution?
> >
>
> Are you sure the web service is giving you 160.44? I get it displayed as
> expected...
>
> http://dev.stut.net/php/pitcher.php
>
Hi,
Yes, I am echoing the 160.44 ok. I'm just not getting the 44c in my display
price. I'm on Windows NT - could that be a factor?
George