Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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
Comment

float vs decimal 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.
Comment

PREVIOUS NEXT
Code Example
Sql :: sql transaction 
Sql :: like operator in sql 
Sql :: what is common table expression in sql 
Sql :: Selecting from a view SQL 
Sql :: create domain sql 
Sql :: update view sql 
Sql :: mac mysql this is incompatible with sql_mode=only_full_group_by 
Sql :: triggers db 
Sql :: sql select distinct 
Sql :: enable mysql query log 
Sql :: identity column in sql server 
Sql :: alter in mysql 
Sql :: how to create notes in mysql 
Sql :: casterar postgres 
Sql :: sql online code 
Sql :: oracle change password expiration policy 
Sql :: how to select only first 3 characters in sql 
Sql :: edad en oracle 
Sql :: oracle apex call duration 
Sql :: from UCSC MySQL database Use database hg38. 
Sql :: create backup 
Sql :: sqlite explain plan 
Sql :: sql Contain declare sample 
Sql :: dumping sql table 
Sql :: query to fetch 50% records from the table. 
Sql :: sql delete row from table where id 
Sql :: unpdate pl sql 
Sql :: sql server: how to assign value to table variable returned from function 
Sql :: PostgresDownload 
Sql :: implizite joins sql 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =