MySQL Forums :: Newbie :: Comparison Between Floating Point Types


Advanced Search

Comparison Between Floating Point Types
Posted by: Tux Penguin ()
Date: November 25, 2012 12:52PM

I inserted different values of pi

3.14
3.14159265359
3.14159
3.1415

And I'm not seeing the difference in how the different floating point types handle the same values.

mysql> select * from types;
+---------+---------+---------+----------+
| flo     | dub     | deci    | noomeric |
+---------+---------+---------+----------+
| 3.14000 | 3.14000 | 3.14000 |  3.14000 |
| 3.14159 | 3.14159 | 3.14159 |  3.14159 |
| 3.14159 | 3.14159 | 3.14159 |  3.14159 |
| 3.14150 | 3.14150 | 3.14150 |  3.14150 |
| 3.14150 | 3.14150 | 3.14150 |  3.14150 |
+---------+---------+---------+----------+
5 rows in set (0.00 sec)

mysql> describe types;
+----------+---------------+------+-----+---------+-------+
| Field    | Type          | Null | Key | Default | Extra |
+----------+---------------+------+-----+---------+-------+
| flo      | float(10,5)   | YES  |     | NULL    |       |
| dub      | double(10,5)  | YES  |     | NULL    |       |
| deci     | decimal(10,5) | YES  |     | NULL    |       |
| noomeric | decimal(10,5) | YES  |     | NULL    |       |
+----------+---------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql>

The only thing I can see here is when creating the table, the field with numeric type used decimal shown by the describe table command.

Would somebody give me an example that shows the differences between FLOAT, DECIMAL and DOUBLE?

Options: ReplyQuote


Subject Written By Posted
Comparison Between Floating Point Types Tux Penguin 11/25/2012 12:52PM
Re: Comparison Between Floating Point Types Rick James 11/27/2012 08:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.