Re: Preserving Decimals
| From: | Mitch Vincent | Date: | Fri, 16 Jun 2000 22:54:09 +0000 |
| Subject: | Re: Preserving Decimals | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-2107@lists.php.net to get a copy of this message | ||
Hey guys, I missed the majority of this thread but judging from the subject
you might want to look at number_format(). Like I said, that might be
totally off-base but I didn't catch most of this thread..
----- Original Message -----
From: Zak Greant <zak@nucleus.com>
To: Yoed Anis <yoed@zarcrom.com>
Cc: <php-general@lists.php.net>
Sent: Friday, June 16, 2000 6:44 PM
Subject: Re: [PHP-GENERAL] Preserving Decimals
> At 05:05 PM 6/16/00 -0500, Yoed Anis wrote:
> >Thanks a lot Zak!
> >This helped me correct the problem.
> >Finally after hours..... ;-)
>
> Hi Yeod,
>
> I am very glad to help! When I first ran into the same problem a bit over
> 2 years ago, I had a devil of a time with it. Instead of figuring out
how
> to use s/printf, I ended up coming up with a solution like this. :)
>
> function OO ($number)
> {
> list ($integer, $remainder) = explode ('.', $number);
>
> switch ( strlen ($remainder))
> {
> case 0:
> return $number . '.00';
> break;
>
> case 1:
> return $number . '0';
> break;
>
> default:
> return $integer . '.' . round ("0.$remainder" *
100);
> }
> }
>
> When I stumbled across my code again about a year after the project, it
> took me a few minutes to figure what it did. I was calling it after every
> mathematical operation for all of my calculations with dollar amount! This
> was one of my first difficult programming projects and I guess that the 0
> truncating behavior must have had me pretty spooked. The funniest thing
is
> that I called it OO because one of its primary functions was adding
> trailing 0s for numeric values.
>
> Um... yeah, that is my pointless anecdote for the day - I hope someone
else
> finds it funny! :)
>
>
> Ciao,
>
>
> Zak Greant
> Creative Director
> Nucleus Information Service Inc.
>
> "I am rather like a mosquito in a nudist camp: I know what I ought to do,
> but I don't know where to begin."
> - Stephen Bayne
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>