Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the difference between float and decimal types in MySQL?
What is the difference between float and decimal types in MySQL?
Online statement

Decimal sum? The difference between floating

Decimal? What data type can be stored at most? 38? Numbers, all numbers can be placed on the right side of the decimal point. Decimal? Data types store accurate digital representations; Do not store approximations.

Definition? Decimal? Two characteristics of columns, variables and parameters are as follows:

? p? The sum of the digits around the decimal point, excluding the decimal point. Like what? 123.45, and then what? p=5,s=2 .

Specifies the precision or number of bits that the object can control.

? s

Specifies the number of decimal places or digits that can be placed to the right of the decimal point.

p? And then what? s? The following rules must be observed: 0? & lt=? s? & lt=? p? & lt=? 38。

Numbers? And then what? Decimal? What is the default maximum precision value of data type? 38。 Are you online? Transact-SQL? In, numerical value? With what? Decimal? Data types are functionally equivalent.

You can use when data values must be stored accurately in a specified way. Decimal? The data type of the stored number.

Floating? And then what? Real? data

Floating? And then what? Real? Data types are called approximate data types. In terms of approximate digital data types, float? And then what? Real? What is the use of data? IEEE? 754? Standard.

Approximate numeric data types do not store the exact values specified for most numbers, they only store the closest values of these values. In many applications, the subtle difference between a specified value and a stored value is not obvious. But sometimes these differences deserve attention. Because? Floating? And then what? Real? This similarity of data types is not used when precise numerical states are needed, such as in financial applications, in operations requiring rounding, or in equivalence checking. In this case, you should use integer, decimal, currency or small currency data types.

Are you online? Where is it? Clauses in search conditions (especially? =? And then what? & lt& gt? Operator), should be avoided? Floating? Or? Real? Column. It is best to limit the use? Floating? And then what? Real? Column >? Or? & lt? Compare.

IEEE? 754? The specification provides four rounding modes: rounding to the nearest value, rounding up, rounding down and rounding to zero. MicrosoftSQL? The server uses rounding. All numerical values must be accurate to a certain degree, but floating-point values will change slightly. Because the binary representation of floating-point numbers can adopt any of many legal rounding rules, it is impossible for us to quantify a floating-point value reliably.

Conversion? Decimal? And then what? Numbers? data

For what? Decimal? And then what? Numbers? Data type, MicrosoftSQL? The server treats each specific combination of precision and scale as a different data type. Like decimal (5,5)? And then what? Decimal (5,0)? Are treated as different data types. (So all variables used in compiling stored procedures are real? Or? Float, not decimal type)

Are you online? Transact-SQL? Statement, constants with decimal points are automatically converted to? Numbers? Data value, and must use the minimum precision and decimal places. Like constants? 12.345? Convert into? Numbers? Value with precision of. 5. What is the decimal place? 3。

From where? Decimal? Or? Numbers? Where to? Floating? Or? Real? Conversion will lead to a loss of accuracy. From where? int、smallint、tinyint、float、real、money? Or? Small money? Where to? Decimal? Or? Numbers? Conversion can lead to overflow.

By default, when converting numbers to lower precision and decimal places. Decimal? Or? Numbers? Value, SQL? Server? Use the rounding method. But what if? Settings? ARITHABORT? What are the options? ON, when overflow occurs, SQL? Server? There will be mistakes. If only precision and decimal places are lost, there will be no error.

Floating? What is the root of scientific counting methods and numerical problems? Floating? The type itself is an inaccurate data representation. That is to say,? If you put a data in, there may be a little error when you take it out. And this small error will lead to inconsistent data when comparing data.