The difference between float and [numeric] (18, 10)

what is the difference between sql server type:

float and [numeric] (18, 10)

+3
source share
3 answers

FLOATmatches IEEE 754and approximates the decimal representation.

NUMERIC is accurate in decimal notation (up to declared accuracy).

SELECT  CAST(PI() AS FLOAT),
        CAST(PI() AS NUMERIC(20, 18)),
        CAST(PI() AS NUMERIC(5, 3))


---------------------- --------------------------------------- ---------------------------------------
3,14159265358979       3.141592653589793100                    3.142
+4
source

numeric - decimal (base-10) fixed-point data type; float - binary (base-2) floating point data type.

[18,10] ( , , ) 18 ( , ). 10. 9 .

.

+2

float .

, (, ) . , , , float , (, ).

Some good links Wikipedia page on IEEE 754 (floating point standard) and David Goldberg ACM article What every computer scientist should know about floating point arithmetic .

0
source

Source: https://habr.com/ru/post/1723379/


All Articles