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 :: Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates. 
Sql :: how to change column name in sql 
Sql :: mysql add column with default value 
Sql :: sqlite data types 
Sql :: mysql separator 
Sql :: set id count mysql 
Sql :: how to truncate table with foreign key constraint postgresql 
Sql :: postgresql casting integer to string 
Sql :: sparql list all graphs 
Sql :: define a variable in mysql from select 
Sql :: savepoint in sql 
Sql :: sql create schema 
Sql :: get all columns from table sql 
Sql :: alter table id autoincrement 
Sql :: username sql 
Sql :: mysql regexp_replace remove html tag 
Sql :: oracle sql pad left zeros 
Sql :: mysql ip address 
Sql :: sql server insert into select 
Sql :: mysql failed to login as root@localhost 
Sql :: mysql union 
Sql :: mysql select true or false 
Sql :: copy value from one column to another postgres 
Sql :: How can I tell how many Cores SQL Server is actually using? 
Sql :: oracle difference between two dates in years 
Sql :: mysql money value 
Sql :: oracle drop job if exists 
Sql :: difference between join vs union 
Sql :: delete a temporary table mysql 
Sql :: MYSQLI_ASYNC 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =