MySQL:float和double有什么区别? [英] MySQL: What's the difference between float and double?

查看:712
本文介绍了MySQL:float和double有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查新的数据库结构后,我发现有人将字段从float更改为double.不知道为什么,我检查了mysql文档,但老实说不明白有什么区别.

Checking in the new database structure I saw that someone changed a field from float to double. Wondering why, I checked the mysql documentation, but honestly didn't understand what the difference is.

有人可以解释吗?

推荐答案

它们都表示浮点数. FLOAT用于单精度,而DOUBLE用于双精度数字.

They both represent floating point numbers. A FLOAT is for single-precision, while a DOUBLE is for double-precision numbers.

MySQL对单精度值使用4个字节,对双精度值使用8个字节.

MySQL uses four bytes for single-precision values and eight bytes for double-precision values.

浮点数和十进制(数字)数有很大的不同,您可以将它们与DECIMAL数据类型一起使用.与浮点数不同,它用于存储精确的数值数据值,而保留精确的精度(例如使用货币数据)很重要.

There is a big difference from floating point numbers and decimal (numeric) numbers, which you can use with the DECIMAL data type. This is used to store exact numeric data values, unlike floating point numbers, where it is important to preserve exact precision, for example with monetary data.

这篇关于MySQL:float和double有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆