]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
New test cases for floating-point conversions.
authordrh <>
Sat, 21 Feb 2026 13:57:40 +0000 (13:57 +0000)
committerdrh <>
Sat, 21 Feb 2026 13:57:40 +0000 (13:57 +0000)
FossilOrigin-Name: 3033fe97b14ba0531278d4aa444bc5340e044b87a72b3a4341032ddee442000f

manifest
manifest.uuid
test/fpconv1.test

index 8108e80e84dc6ae68d25a13826ba63ff8106f9cc..c3151a0aaab37af12100862356155ae3470f9ab7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\san\sunreachable\sbranch.
-D 2026-02-21T13:40:07.301
+C New\stest\scases\sfor\sfloating-point\sconversions.
+D 2026-02-21T13:57:40.503
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -1131,7 +1131,7 @@ F test/fordelete.test ba98f14446b310f9c9d935b97ec748753d0144a28b356ba30d1f4f6958
 F test/fork-test.c 9ac2e6423a1d38df3d6be0e8ac15608b545de21e2b19d9d876254c5931b63edb
 F test/format4.test eeae341953db8b6bda7f549044797c3278a6cc345d11ada81471671b654f8ef4
 F test/fp-speed-1.c b37de94eba034e1703668816225f54510ec60fb0685406608cc707afe6b8234d
-F test/fpconv1.test ac9616f36ac8b8bc16b78f389978d8fb1420f53c1fc93d2793a9553ca2755f72
+F test/fpconv1.test d9e1e1bdeaf22b2e800aa6847466468a930f6aea6b59eea348711f9445a043b1
 F test/fts-9fd058691.test 78b887e30ae6816df0e1fed6259de4b5a64ad33c
 F test/fts3.test 672a040ea57036fb4b6fdc09027c18d7d24ab654
 F test/fts3_common.tcl dffad248f9ce090800e272017d2898005c28ee6314fc1dd5550643a02666907a
@@ -2195,8 +2195,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P ef0049e3ade304f64e1ab97e52e1e21379e4db461f3fa80dac8e544fb90d622f
-R 4284bb3336406325134043995228dfd1
+P 93f90eacc0c5b2ae0042ec525359298883f8473e24967208feef4029d9fa2d08
+R e68f89bae9b5fbd05cf0e0e735a13171
 U drh
-Z 6f1ea06f09642b6d8ff481a030d40fdb
+Z 5a9c96d60317e775f664966a4b06b2ad
 # Remove this line to create a well-formed Fossil manifest.
index f50a9520fafde3104bffbeae0a0acce272ecb1ff..f51a8bda13147e19d8e98da3d97df1fce16b9c5a 100644 (file)
@@ -1 +1 @@
-93f90eacc0c5b2ae0042ec525359298883f8473e24967208feef4029d9fa2d08
+3033fe97b14ba0531278d4aa444bc5340e044b87a72b3a4341032ddee442000f
index 7b052d78b280d57b839603aa91748926ead3ae54..597e065e8b2fb7dc1e3e92cf9938505a31962569 100644 (file)
@@ -28,18 +28,59 @@ do_execsql_test fpconv1-1.0 {
        /* Number of random floating-point values to try.
        ** On a circa 2021 Ryzen 5950X running Mint Linux, and
        ** compiled with -O0 -DSQLITE_DEBUG, this test runs at
-       ** about 150000 cases per second  ------------------vvvvvv */
-    c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<900000),
+       ** about 150000 cases per second  ------------------vvvvvvv */
+    c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<500_000),
     fp(y) AS MATERIALIZED (
        SELECT CAST( format('%+d.%019d0e%+03d',
                            random()%10,abs(random()),random()%200) AS real)
         FROM c
     )
   SELECT y FROM fp
-   WHERE -log10(abs(decimal_sub(dtostr(y,24),format('%!.24e',y))/y))<16.0;
+   WHERE -log10(abs(decimal_sub(dtostr(y,24),format('%!.24e',y))/y))<17.0;
                      /* Number of digits of accuracy required -------^^^^ */
 } {}
 #  ^---- Expect a empty set as the result.  The output is all tested numbers
 #        that fail to preserve at least 16 significant digits of accuracy.
 
+########################################################################
+# Random test to ensure that double -> text -> double conversions
+# round-trip exactly.
+#
+
+load_static_extension db ieee754
+
+do_execsql_test fpconv1-2.0 {
+  WITH RECURSIVE
+    c(x,s) AS MATERIALIZED (VALUES(1,random()&0xffefffffffffffff)
+               UNION ALL
+               SELECT x+1,random()&0xffefffffffffffff
+                 FROM c WHERE x<1_000_000),
+    fp(y,s) AS (
+       SELECT ieee754_from_int(s),s FROM c
+    ),
+    fp2(yt,y,s) AS (
+       SELECT y||'', y, s FROM fp
+    )
+  SELECT format('%#016x',s) aS 'orig-hex',
+         format('%#016x',ieee754_to_int(CAST(yt AS real))) AS 'full-roundtrip',
+         yt AS 'rendered-as',
+         decimal_exp(yt,30) AS 'text-decimal',
+         decimal_exp(ieee754_from_int(s),30) AS 'float-decimal'
+    FROM fp2
+   WHERE ieee754_to_int(CAST(yt AS real))<>s;
+} {}
+#  ^---- Values that fail to round-trip will be reported
+
+# Unusual rendering cases:
+#
+do_execsql_test fpconv1-3.0 {
+  SELECT 1.23 - 2.34;
+} {-1.1099999999999999}
+#  ^---  Not -1.11 as you would expect.  -1.11 has a different bit pattern
+
+do_execsql_test fpconv1-3.1 {
+  SELECT 1.23 * 2.34;
+} {2.8781999999999996}
+#  ^---  Not 2.8782 as you would expect.  2.8782 has a different bit pattern
+
 finish_test