Re: PHP 4.2.2 Float->Mysql addition problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

>I forget the rules of float contagion in PHP, but it "should" work, I
>would expect...

That's what i also did, though.

>I don't suppose that by sheer chance the decimal portions add up to an
>even integer?...
>0.3333 + 0.6666
>might, for example, turn into: 1
>(Or might not, depending on a low-level float implementation)

It prints out 0.9999

>Some other options:
>Cast them in MySQl and let MySQL add them up.

Works fine, just needs 3 seconds for the query.
3 seconds for the table + 3 seconds for the summary.
This is taking a bit to long ;)

>I forget MySQL's typecast operator/function, but it's in the manual:
>http://dev.mysql.com
>Something like:
>select sum(cast(floatval, 'decimal')) from somewhere
>
>You may also need to use coalesce to change NULL into 0.
>
>You'd have to tell use what the actual string values ARE for us to do
>any more than guess, though.

Normal prices like:
345.76
234.09
324.54

And so on

Greets
	Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux