double and substraction
| From: | Martin Dolog | Date: | Thu, 06 Apr 2000 07:46:44 +0000 |
| Subject: | double and substraction | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-17665@lists.php.net to get a copy of this message | ||
Hi Guru(s),
I'm running php3.0.12 w/ Mysql3.22.27 on
Linux/i686 & Solaris/Sparc;
My problem is about substracion two
numbers - doubles. The frist one
is from DB, a column specified as
DOUBLE(10,3) and the second one is a
DOUBLE
variable in PHP3 script file.
$a = (double) 0.0;
//$r id result set
<loop>
...
$a -= $r["double_col_name"];
echo $a;
...
<end_loop>
problem is that substraction of some
numbers is not correct,
exactly if:
$a = 534.31;
$r["double_col_name"] = 500;
then after $a - $r["..."] I got
34.31000000002
What is a disaster!
I tried almost everything ... :-((
Please help me!
THANKS A LOT
martin
--
#md