Re: The 85/0.0085 mistery ?

Поиск
Список
Период
Сортировка
От Jean-Christophe Pazzaglia
Тема Re: The 85/0.0085 mistery ?
Дата
Msg-id 39DDDCB1.4298CA38@albourne.com
обсуждение исходный текст
Ответ на RE: The 85/0.0085 mistery ?  ("Frederick W. Reimer" <fwr@ga.prestige.net>)
Список pgsql-hackers
"Frederick W. Reimer" wrote:
>
> Nothing is wrong, that's just how computers work.  Fractional numbers are
> stored in a variety of formats on different platforms.  Most support the
> IEEE formats, but some use their own formats.  In all cases, that I'm aware
> of, the numbers are stored as a mantissa and exponent.  The numbers are
> "base 2", so certain base 10 numbers don't have an exact representation in
> base 2, no matter how many bits are used in the mantissa.  Other base 10
> numbers have problems with the "short" mantissa formats, but are represented
> exactly with the "long" mantissa formats.

thank you for the lesson,
I probably have done too much database this time :o

what I was really affraid was the BUT clause ...

> >  jctest=> select * from eigthyfive where (cs/csbytenthousand=10000);
> >  cs | csbytenthousand | csbyhundred
> > ----+-----------------+-------------
> >  88 |          0.0088 |        0.88
> >  86 |          0.0086 |        0.86
> >  84 |          0.0084 |        0.84
> > (3 rows)
> >
> > *** oh oh 85 disappeared ! ***
> >
> > BUT
> >
> > jctest=> select (85/0.0085=10000);
> >  ?column?
> > ----------
> >  t
> > (1 row)

... It seems that this is due to the single precision
(float4) instead of double precision (float)
(and even with a test done in base 3 :P)
BTW there is no round(float4) function

thanks

jc
Вложения

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

Предыдущее
От: "Frederick W. Reimer"
Дата:
Сообщение: RE: The 85/0.0085 mistery ?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: The 85/0.0085 mistery ?