Commit Graph

18 Commits

Author SHA1 Message Date
Tom Lane 5e7c3d91bf Add documentation and regression tests concerning rounding of numerics.
Michael Paquier, reviewed by Fabien Coelho
2015-07-03 17:04:39 -04:00
Tom Lane 06bf0dd6e3 Upgrade src/port/rint.c to be POSIX-compliant.
The POSIX spec says that rint() rounds halfway cases to nearest even.
Our substitute implementation failed to do that, rather rounding halfway
cases away from zero; and it also got some other cases (such as minus
zero) wrong.  This led to observable cross-platform differences, as
reported in bug #12885 from Rich Schaaf; in particular, casting from
float to int didn't honor round-to-nearest-even on builds using rint.c.

Implement something that attempts to cover all cases per spec, and add
some simple regression tests so that we'll notice if any platforms still
get this wrong.

Although this is a bug fix, no back-patch, as a behavioral change in
the back branches was agreed not to be a good idea.

Pedro Gimeno Fortea, reviewed by Michael Paquier and myself
2015-03-25 15:54:18 -04:00
Tom Lane 1f7cb5c309 Improve handling of INT_MIN / -1 and related cases.
Some platforms throw an exception for this division, rather than returning
a necessarily-overflowed result.  Since we were testing for overflow after
the fact, an exception isn't nice.  We can avoid the problem by treating
division by -1 as negation.

Add some regression tests so that we'll find out if any compilers try to
optimize away the overflow check conditions.

This ought to be back-patched, but I'm going to see what the buildfarm
reports about the regression tests first.

Per discussion with Xi Wang, though this is different from the patch he
submitted.
2012-11-19 12:24:25 -05:00
Peter Eisentraut fc946c39ae Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
Robert Haas e8bf683fbe Update int8-exp-three-digits.out to match new contents of int8.out. 2010-11-20 07:06:52 -05:00
Tom Lane af88c9bbec Fix a missed case in int8-exp-three-digits.out, per buildfarm results. 2008-10-06 00:07:28 +00:00
Peter Eisentraut 6151e89e8b Remove some unportable tests 2008-10-05 18:56:09 +00:00
Peter Eisentraut d112ead206 Reverse int8.out and int8-exp-three-digits.out mixup. 2008-10-05 15:46:35 +00:00
Peter Eisentraut 34411cfac5 Additional test coverage for int8 type (int8.c)
int8-exp-three-digits.out update untested, might need refinement.
2008-10-05 14:26:30 +00:00
Tom Lane b153c09209 Add a bunch of new error location reports to parse-analysis error messages.
There are still some weak spots around JOIN USING and relation alias lists,
but most errors reported within backend/parser/ now have locations.
2008-09-01 20:42:46 +00:00
Tom Lane 8cb4e4f6bd Add regression test to see if the min/max values of int8 convert correctly. 2005-12-05 04:13:38 +00:00
Tom Lane 3cbd6bc308 Fix overlooked regression output file. 2005-06-26 17:20:04 +00:00
Tom Lane 4171bb869f Detect overflow in integer arithmetic operators (integer, smallint, and
bigint variants).  Clean up some inconsistencies in error message wording.
Fix scanint8 to allow trailing whitespace in INT64_MIN case.  Update
int8-exp-three-digits.out, which seems to have been ignored by the last
couple of people to modify the int8 regression test, and remove
int8-exp-three-digits-win32.out which is thereby exposed as redundant.
2004-10-04 14:42:48 +00:00
Tom Lane 4e5c2a8d52 Update regression expected results for to_char() change. 2002-09-20 16:44:55 +00:00
Tom Lane b78d1bed07 Change float8-to-int8 conversion to round to nearest, rather than
truncating to integer.  Remove regress test that checks whether
4567890123456789 can be converted to float without loss; since that's
52 bits, it's on the hairy edge of failing with IEEE float8s, and indeed
rint seems to give platform-dependent results for it.
2001-01-26 22:50:26 +00:00
Tom Lane 6a2d926933 Update for to_char change. 2000-04-08 02:02:26 +00:00
Tom Lane 418cf04987 Update from Andreas Kardos. 2000-03-31 05:36:54 +00:00
Bruce Momjian 8daa31a21e Add QNX fixes from Kardos, Dr. Andreas 2000-03-01 19:11:12 +00:00