Re: MySQL and PHP math problem...

From: Date: Sat, 09 Nov 2002 17:03:15 +0000
Subject: Re: MySQL and PHP math problem...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-123596@lists.php.net to get a copy of this message
Thanks...the thing that I did wrong was I retrieved the number with FORMAT(SUM(amount), 2), which formats the number and return it in the string format...so that's what happened during the computation (it only took the number prior to the ','. I miss the type-checking in C. :-) Thanks, -Peter "@ Edwin" <copperwalls@hotmail.com> wrote in message news:20021109134728.65621.qmail@pb1.pair.com... > Hello, > > "Peter" <rpete@hotmail.com> wrote in message > news:20021109065959.35268.qmail@pb1.pair.com... > > ...[snip]... > > > the result of echo, $tmp is displayed as '0.0002'. What's wrong here? > The > > problem only occurs when the value is greater than a 1,000? Could the ',' > > messed the computation up somehow? > > I think so because > > 1/5000 = 0.0002 > > (Only the number *before* the ',' is being used.) > > Try taking away the ',' then by using str_replace() and calculate again. > > - E >

« previous php.general (#123596) next »