“SQL Decimal vs Float” Kode Jawaban

SQL Decimal vs Float

Float is Approximate-number data type, which means that not all values in the data type range can be represented exactly.

Decimal/Numeric is Fixed-Precision data type, which means that all the values in the data type range can be represented exactly with precision and scale. You can use decimal for money saving.

Converting from Decimal or Numeric to float can cause some loss of precision. 

Not a complete answer, but a useful link:

"I frequently do calculations against decimal values. In some cases casting decimal values to float ASAP, prior to any calculations, yields better accuracy. "

http://sqlblog.com/blogs/alexander_kuznetsov/archive/2008/12/20/for-better-precision-cast-decimals-before-calculations.aspx
Delta Sierra

float vs desimal sql

Here are the differences per https://www.w3schools.com/mysql/mysql_datatypes.asp

FLOAT(size, d)	A floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. This syntax is deprecated in MySQL 8.0.17, and it will be removed in future MySQL versions

DECIMAL(size, d)	An exact fixed-point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. The maximum number for size is 65. The maximum number for d is 30. The default value for size is 10. The default value for d is 0.
CompSciGeek

Jawaban yang mirip dengan “SQL Decimal vs Float”

Pertanyaan yang mirip dengan “SQL Decimal vs Float”

Lebih banyak jawaban terkait untuk “SQL Decimal vs Float” di Sql

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya