Get the App
SLTechnology News&Howtos  ›  Database  › 

Example Analysis of floating-point number and fixed-point number in MySQL

Shulou Source: shulou.com Published: 2022-05-31 13:59:18 09月26日 Update

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!

Tags: Points analysis content reality more knowledge practicality achievement next single precision dilemma character string actually form situation data article case precision Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Tech Info Redmi MySQL OPPO Reno