Skip to content

Commit

Permalink
Fix non-portable use of round().
Browse files Browse the repository at this point in the history
round() is from C99.  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 51bc271.

Per buildfarm member thrips.

Author: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzn76eCGUonARy-wrVtMHsf+4cvbK_oJAWTLfORTU5ki0w@mail.gmail.com
  • Loading branch information
anarazel committed Apr 1, 2018
1 parent 7f563c0 commit 686d399
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/backend/lib/bloomfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 686d399

Please sign in to comment.