Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is SQL Server 'MONEY' data type a decimal floating point or binary floating point?

I couldn't find anything that rejects or confirms whether SQL Server 'MONEY' data type is a decimal floating point or binary floating point.

In the description it says that MONEY type range is from -2^63 to 2^63 - 1 so this kind of implies that it should be a binary floating point.

But on this page it lists MONEY as "exact" numeric. Which kind of suggests that MONEY might be a decimal floating point (otherwise how is it exact? or what is the definition of exact?)

Then if MONEY is a decimal floating point, then what is the difference between MONEY and DECIMAL(19,4) ?

like image 259
kaptan Avatar asked Feb 22 '10 20:02

kaptan


People also ask

What is the float data type in SQL Server?

Float is an approximate number data type used to store a floating-point number. float (n) - n is the number of bits that are used to store the mantissa in scientific notation. Range of values: - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308. Storage size: 4 Bytes if n = 1-9 and 8 Bytes if n = 25-53 – default = ...

What is the difference between money and decimal data types in SQL Server?

Money is stored in the same way an integer is stored, whereas decimal is stored as a decimal point and decimal digits. This means that money will drop accuracy in most cases, while decimal will only do so when converted back to its original scale. Money is fixed point, so its scale doesn't change during calculations.

Does SQL have float data type?

The SQL Server float[(n)] data type complies with the ISO standard for all values of n from 1 through 53. The synonym for double precision is float(53).


1 Answers

Neither. If it were an implementation of floating point it would be subject to the same inaccuracies as FLOAT and REAL types. See Floating Point on wikipedia.

MONEY is a fixed point type.

It's one byte smaller than a DECIMAL(19,4), because it has a smaller range (922,337,203,685,477.5808 to 922,337,203,685,477.5807) as opposed to (-10^15+1 to 10^15-1).

like image 112
hobodave Avatar answered Sep 21 '22 05:09

hobodave