Re: Real type with zero

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Real type with zero
Дата
Msg-id 4E0B2D9F.4000503@postnewspapers.com.au
обсуждение исходный текст
Ответ на Real type with zero  (Condor <condor@stz-bg.com>)
Список pgsql-general
On 29/06/2011 7:24 PM, Condor wrote:
> Hello,
> how I can tell my postgresql to store last zero of real type ? I put
> value 2.30 and when I select that column i see 2.3 without zero.

The real data type is an IEEE 754 floating point number. See:

http://en.wikipedia.org/wiki/Floating_point
http://steve.hollasch.net/cgindex/coding/ieeefloat.html

It doesn't store any information about formatting or layout. If you want
to retain that information, you'll need to use NUMERIC or just store
your numbers as formatted strings. Note that NUMERIC doesn't store error
ranges and its formatting isn't preserved by most arithmetic operations;
it's not a full scientific error-bounded numeric type.

regress=> SELECT '4401.00100'::numeric;
   numeric
------------
  4401.00100
(1 row)

regress=> SELECT '4401.00100'::float;
   float8
----------
  4401.001
(1 row)

--
Craig Ringer

В списке pgsql-general по дате отправления:

Предыдущее
От: Radoslaw Smogura
Дата:
Сообщение: Re: Real type with zero
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: point types in "DISTINCT" queries