Re: PHP 4.2.2 Float->Mysql addition problem

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

 




It's possible that MySQL has larger range of floats than PHP.

Then when your numbers come in, PHP ends up making them be things like:
'NaN' (not a number) or '6.02e+23' or ...

There are a LOT of ways to represent floats in such a way that you can
confuse the heck out of PHP and MySQL between the two of them.

You really need to figure out where/how your calculcations should be
made to get the sort of range and precision you need.

On Fri, February 3, 2006 6:32 am, Barry wrote:
> Andrei wrote:
>>     When working with floats with php/mysql I had problems too...
>> When
>> summing amounts I had errors so my solution was using decimal (20,
>> 10)
>> type into mysql for storing amounts and when using sums in php I
>> used bc
>> functions. This way u get exact calculations (depending on bcscale()
>> parameter.
>
>
> Thanks Andy sounds great.
> Changed DB to decimal 10.2
>
> Tried it, but using bcadd i get a value of 0.00.
>
> If you have som sample code lying around somewhere that would be
> great,
> or do you know what happened?
>
> 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
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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