Re: int4, int8, real ....division... - Mailing list pgsql-bugs

From Tom Lane
Subject Re: int4, int8, real ....division...
Date
Msg-id 2110.1085071301@sss.pgh.pa.us
Whole thread Raw
In response to int4, int8, real ....division...  ("Gyenese Pál Attila" <gyenese@mediagnost.hu>)
Responses Re: int4, int8, real ....division...
List pgsql-bugs
"Gyenese Pál Attila" <gyenese@mediagnost.hu> writes:
> REASON IS:

> SELECT 365*10000000 ;
> result: -644967296
> wrong

This isn't a division problem --- the difficulty is there's no check for
overflow in int4 multiplication.  (Nor in any of the other integer
arithmetic operations, for that matter.)

It'd be nice if C made it easier to detect integer overflow :-(
... AFAIK, testing this would make those subroutines many times slower,
which is pretty annoying when the hardware already knows whether the
result overflowed or not.
        regards, tom lane


pgsql-bugs by date:

Previous
From: "Gyenese Pál Attila"
Date:
Subject: int4, int8, real ....division...
Next
From: Fabien COELHO
Date:
Subject: Re: BUG #1145: silent REVOKE failures