walt wrote:
> I've run into a weird problem. If I try to insert this value, 78978978,
> into a FLOAT(9,2) column, the value changes. See below.
> System info:
> MySQL-shared-3.23.51-1
> MySQL-client-3.23.51-1
> MySQL-devel-3.23.51-1
> MySQL-Max-3.23.51-1
> MySQL-3.23.51-1
> Red Hat Linux release 7.3 (Valhalla)
> 
> #####Wrong
> mysql> CREATE TABLE TIMMA ( AMOUNT FLOAT(10,2));
> Query OK, 0 rows affected (0.01 sec)
> 
> mysql> INSERT INTO TIMMA VALUES(78978978);
> Query OK, 1 row affected (0.00 sec)
> 
> mysql> SELECT * FROM TIMMA;
> +-------------+
> | AMOUNT      |
> +-------------+
> | 78978976.00 |
> +-------------+
> 1 row in set (0.00 sec)
> 
> #####Try again with different value
> mysql> DROP TABLE TIMMA;
> Query OK, 0 rows affected (0.00 sec)
> 
> mysql> CREATE TABLE TIMMA ( AMOUNT FLOAT(10,2));
> Query OK, 0 rows affected (0.00 sec)
> 
> mysql> INSERT INTO TIMMA VALUES(98978978);
> Query OK, 1 row affected (0.01 sec)
> 
> mysql> SELECT * FROM TIMMA;
> +-------------+
> | AMOUNT      |
> +-------------+
> | 98978976.00 |
> +-------------+
> 1 row in set (0.00 sec)
> 
> sql, query

Hi,

FLOAT values are stored internally as 32 bits floating point values
that have only 6 or 7 significant digits. If you want more significant
digits you should use DOUBLE or DECIMAL types instead.

Regards
-- 
Joseph Bueno


---------------------------------------------------------------------
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 <mysql-unsubscribe-##L=##[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to