Hi,
You should specify your float like this:
create table ft (id INT NOT NULL AUTO_INCREMENT, val FLOAT (10,2), PRIMARY
KEY(id));
mysql> create table ft (id INT NOT NULL AUTO_INCREMENT, val FLOAT (10,2),
PRIMARY KEY(id));
Query OK, 0 rows affected (0.02 sec)
mysql> insert ft(val) values('3.4');
Query OK, 1 row affected (0.00 sec)
mysql> insert ft(val) values('0.3');
Query OK, 1 row affected (0.00 sec)
mysql> insert ft(val) values('1.24');
Query OK, 1 row affected (0.00 sec)
mysql> select sum(val) from ft;
+----------+
| sum(val) |
+----------+
| 4.94 |
+----------+
1 row in set (0.00 sec)
==>> >> FLOAT (10,2)
Regards,
Almar van Pel
-----Oorspronkelijk bericht-----
Van: M. A. Alves [mailto:[EMAIL PROTECTED]]
Verzonden: donderdag, december 13, 2001 16.47
Aan: Wojciech Dr��ek
CC: [EMAIL PROTECTED]
Onderwerp: Re: Problems with function sum() on float values
On Thu, 13 Dec 2001, [iso-8859-2] Wojciech Dr��ek wrote:
>
> I wonder if it is only question of configuration but my MySQL server has
> problems with suming of float values.
>
> create table ft (id INT AUTO_INCREMENT, val FLOAT , PRIMARY KEY(id));
> insert ft(val) values('3.4');
> insert ft(val) values('0.3');
> insert ft(val) values('1.24');
> . . .
Same problem here viz:
select sum(val) from ft; => 4.9400001168251
while
select 3.4 + 0.3 + 1.24; => 4.94
According to a previous message on this forum today, there are known
problems with the float type. Maybe this is one of them (in the function
sum).
--
,
M A R I O data miner, LIACC, room 221 tel 351+226078830, ext 121
A M A D O Rua Campo Alegre, 823 fax 351+226003654
A L V E S P-4150-180 PORTO, Portugal mob 351+939354002
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php