Significant Digits in Floating Point Datatype - Mailing list pgsql-general

From Lee Hachadoorian
Subject Significant Digits in Floating Point Datatype
Date
Msg-id 4EC94711.4000007@gmail.com
Whole thread Raw
Responses Re: Significant Digits in Floating Point Datatype  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Significant Digits in Floating Point Datatype  (Bill Moran <wmoran@potentialtech.com>)
List pgsql-general
I would like to store some in a single array some data that is
conceptually related, but some of the data is floating point, and some
of it is integer. Obviously the integer data *can* be stored as double
precision, but I need to know about potential loss of precision. Double
precision has "a precision of at least 15 digits." I would assume that
that would mean that for double precision, 15 digits of data would be
faithfully preserved. But I found a question on the list where a value
stored as 955.60 sometimes returns as 955.599999999998.
(http://archives.postgresql.org/pgsql-general/2011-08/msg00144.php) If
this is the case, what does "a precision of at least [x] digits"
actually mean? And can I reliably retrieve the original integer by
casting to int (or bigint) if the number of digits in the original
integer is less than 15?

Regards,
--Lee

--
Lee Hachadoorian
PhD, Earth&  Environmental Sciences (Geography)
Research Associate, CUNY Center for Urban Research
http://freecity.commons.gc.cuny.edu


pgsql-general by date:

Previous
From: Raghavendra
Date:
Subject: How to install pgfincore with PG 9.1
Next
From: Scott Marlowe
Date:
Subject: Re: Installed. Now what?