On Sat, Mar 31, 2018 at 8:09 PM, Peter Geoghegan <p...@bowt.ie> wrote: > I was thinking of using rint(), which is what you get if you call > round(float8) from SQL.
Attached patch does it that way. Note that there are float/int cast regression tests that ensure that rint() behaves consistently on supported platforms -- see commit 06bf0dd6. -- Peter Geoghegan
From ff0bd32d33ceb6b5650e28d76ee794961862a4fc Mon Sep 17 00:00:00 2001 From: Peter Geoghegan <p...@bowt.ie> Date: Sat, 31 Mar 2018 19:54:48 -0700 Subject: [PATCH] Fix non-portable call to round(). round() is from C99. Apparently, not all supported versions of Visual Studio make it available. Use rint() instead. There are behavioral differences between round() and rint(), but they should not matter to the Bloom filter optimal_k() function. We already assume POSIX behavior for rint(), so there is no question of rint() not using "rounds towards nearest" as its rounding mode. Cleanup from commit 51bc271790eb234a1ba4d14d3e6530f70de92ab5. Per buildfarm member thrips. Author: Peter Geoghegan --- src/backend/lib/bloomfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/lib/bloomfilter.c b/src/backend/lib/bloomfilter.c index eb08f4a..3565480 100644 --- a/src/backend/lib/bloomfilter.c +++ b/src/backend/lib/bloomfilter.c @@ -240,7 +240,7 @@ my_bloom_power(uint64 target_bitset_bits) static int optimal_k(uint64 bitset_bits, int64 total_elems) { - int k = round(log(2.0) * bitset_bits / total_elems); + int k = rint(log(2.0) * bitset_bits / total_elems); return Max(1, Min(k, MAX_HASH_FUNCS)); } -- 2.7.4