From: Tom Lane Date: Tue, 10 Jan 2023 03:44:16 +0000 (-0500) Subject: Round off random_normal() test results one more decimal place. X-Git-Tag: REL_16_BETA1~967 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=02d552c4f4229c3c1fb4ed5eadb93b6d551b7510;p=postgresql.git Round off random_normal() test results one more decimal place. As I suspected, some machines have even more low-order-bit inaccuracy than the ones I tested. Tweak new test so that (hopefully) it will pass everywhere. Per buildfarm. Discussion: https://postgr.es/m/4173840.1673290336@sss.pgh.pa.us --- diff --git a/src/test/regress/expected/random.out b/src/test/regress/expected/random.out index 8ffb0fcfc44..6dbb43ab2d5 100644 --- a/src/test/regress/expected/random.out +++ b/src/test/regress/expected/random.out @@ -113,34 +113,34 @@ SELECT random() FROM generate_series(1, 10); -- Likewise for random_normal(); however, since its implementation relies -- on libm functions that have different roundoff behaviors on different -- machines, we have to round off the results a bit to get consistent output. -SET extra_float_digits = 0; +SET extra_float_digits = -1; SELECT random_normal() FROM generate_series(1, 10); - random_normal --------------------- - 0.208534644938377 - 0.264530240540963 - -0.606752467900428 - 0.825799427852654 - 1.70111611735357 - -0.223445463716189 - 0.249712419190998 - -1.2494722990669 - 0.125627152043677 - 0.475391614544013 + random_normal +------------------- + 0.20853464493838 + 0.26453024054096 + -0.60675246790043 + 0.82579942785265 + 1.7011161173536 + -0.22344546371619 + 0.249712419191 + -1.2494722990669 + 0.12562715204368 + 0.47539161454401 (10 rows) SELECT random_normal(mean => 1, stddev => 0.1) r FROM generate_series(1, 10); - r -------------------- - 1.00605972811732 - 1.09685453015002 - 1.02869206132007 - 0.909475676712336 - 0.983724763134265 - 0.939344549577623 - 1.18713500206363 - 0.962257684292933 - 0.914441206800407 - 0.964031055575433 + r +------------------ + 1.0060597281173 + 1.09685453015 + 1.0286920613201 + 0.90947567671234 + 0.98372476313426 + 0.93934454957762 + 1.1871350020636 + 0.96225768429293 + 0.91444120680041 + 0.96403105557543 (10 rows) diff --git a/src/test/regress/sql/random.sql b/src/test/regress/sql/random.sql index 088c451b850..6e99e2e60cf 100644 --- a/src/test/regress/sql/random.sql +++ b/src/test/regress/sql/random.sql @@ -79,7 +79,7 @@ SELECT random() FROM generate_series(1, 10); -- Likewise for random_normal(); however, since its implementation relies -- on libm functions that have different roundoff behaviors on different -- machines, we have to round off the results a bit to get consistent output. -SET extra_float_digits = 0; +SET extra_float_digits = -1; SELECT random_normal() FROM generate_series(1, 10); SELECT random_normal(mean => 1, stddev => 0.1) r FROM generate_series(1, 10);