Round off random_normal() test results one more decimal place.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 10 Jan 2023 03:44:16 +0000 (22:44 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 10 Jan 2023 03:44:16 +0000 (22:44 -0500)
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

src/test/regress/expected/random.out
src/test/regress/sql/random.sql

index 8ffb0fcfc44231478bc2e51674731408758f409e..6dbb43ab2d5e252fa7acc0e2c942577ccf950edb 100644 (file)
@@ -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)
 
index 088c451b850172024dd6fba2475d5f14ec1e8fe8..6e99e2e60cf56b77810ff09ed74ae460b532a57e 100644 (file)
@@ -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);