Subject | Re: [firebird-support] DATA TYPES - float and so on |
---|---|
Author | Ivan Prenosil |
Post date | 2008-02-01T12:01:47Z |
> someone could explain exactly difference between these data types:DOUBLE PRECISION - it is standard floating point type,
>
> DECIMAL
> FLOAT
> DOUBLE
> NUMERIC
>
> naturally in firebird....
advantage is that it can store very big and very small values
(like number of atoms in universe or wavelength of light),
disadvantage is that it is not precise, .e.g. it can't store
value "0.1" exactly, instead it will store something like
"0.0999999999999999". This fact is usually hidden
by different built-in roundings, but you should be aware of it.
FLOAT - similar do Double Precision, but Double is 8-bytes
and Float is 4-bytes. Because of its poor precision
you should avoid it.
DECIMAL and NUMERIC are exact types (internally stored
as Integer or Bigint), more suitable e.g. for handling money.
Small problem is that such types are usually not supported
directly by programming languages. E.g. in Delphi there is
datatype "Currency", which is equivalent to NUMERIC(18,4),
but for handling NUMERIC(18,5) you would probably need
to use Extended (which is similar to Double, but has better
precision since it is stored in 10 bytes)
You can find some notes here:
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=fb_conf_timetable_2006
(slides for "Data types" presentation)
Ivan