Example Analysis of floating-point number and fixed-point number in MySQL
This article introduces the relevant knowledge of "floating-point and fixed-point example analysis of MySQL". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Single-precision floating-point numbers will produce errors. In applications that require high precision, fixed-point numbers should be used to save data. Fixed-point numbers are actually stored in the form of strings.
Mysql > create table test (C1 float (10Magne2), c2 double (10Magne2), c3 decimal (10Magne2))
Query OK, 0 rows affected (0.17 sec)
Mysql > insert into test values (851028.52, 851028.52)
Query OK, 1 row affected (0.02 sec)
Mysql > insert into test values (851028.42) 851028.52)
Query OK, 1 row affected (0.03 sec)
Mysql > select * from test
+-+
| | C1 | c2 | c3 |
+-+
| | 851028.50 | 851028.52 | 851028.52 | |
| | 851028.44 | 851028.52 | 851028.52 | |
+-+
2 rows in set (0.00 sec)
This is the end of the content of "floating-point and fixed-point example Analysis of MySQL". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!