Re: BUG in postgres mathematic
От | Robert B. Easter |
---|---|
Тема | Re: BUG in postgres mathematic |
Дата | |
Msg-id | 0101250729000J.08820@comptechnews обсуждение исходный текст |
Ответ на | BUG in postgres mathematic (Max Vaschenko <max@nino.ru>) |
Ответы |
Re: BUG in postgres mathematic
|
Список | pgsql-bugs |
This problem is not specific to Postgres. If you play around with a little C program like: #include <stdio.h> int main(int argc, char * argv[]) { float f = 27.81; int i = 5; int l = 100; int ii = i*f*l; long ll = l*f*i; float ff = i*f*l; printf("%i\n", ii); printf("%li\n", ll); printf("%.5f\n", ff); printf("%i\n", (int) ff); } It prints: 13904 13904 13905.00000 13905 There is probably a good explanation for this. gcc 2.95 and egcs 2.91.66 do this. Maybe a rounding problem. On Thursday 25 January 2001 05:34, Max Vaschenko wrote: > Postgres-7.0.3-2 > RedHat-6.2 > > SELECT int8(5*27.81*100); > 13904 > > SELECT int4(5*27.81*100); > 13905 > > SELECT int8(27.81*100*5); > 13905 -- -------- Robert B. Easter reaster@comptechnews.com --------- -- CompTechNews Message Board http://www.comptechnews.com/ -- -- CompTechServ Tech Services http://www.comptechserv.com/ -- ---------- http://www.comptechnews.com/~reaster/ ------------
В списке pgsql-bugs по дате отправления: