]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improvements to rounding behavior in the new floating-point conversion logic.
authordrh <>
Thu, 19 Feb 2026 12:59:42 +0000 (12:59 +0000)
committerdrh <>
Thu, 19 Feb 2026 12:59:42 +0000 (12:59 +0000)
FossilOrigin-Name: e540f6c370675ae043af8cdbb80f7eb17c08e50f7634e0b78f0b1dccf7bd4b18

manifest
manifest.uuid
src/util.c

index dd756e1ee4fcbad0586f85220c412a32bb204b21..80396f18d7f97a04d1a1d401d9a2b6c9fcdf8337 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Restore\sthe\sCLI\sfunction\sdtostr()\sback\sto\sits\soriginal\spurpose\sof\sconverting\nfloating\spoint\svalues\sto\sdecimal\susing\sthe\shost\scomputer's\sC-library.
-D 2026-02-17T20:28:25.509
+C Improvements\sto\srounding\sbehavior\sin\sthe\snew\sfloating-point\sconversion\slogic.
+D 2026-02-19T12:59:42.005
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -803,7 +803,7 @@ F src/trigger.c a40440614bdf523090cc07223f4878f7e3c892bcd1a13afe18f90190daa5945d
 F src/update.c 3e5e7ff66fa19ebe4d1b113d480639a24cc1175adbefabbd1a948a07f28e37cf
 F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1
 F src/utf.c 7267c3fb9e2467020507601af3354c2446c61f444387e094c779dccd5ca62165
-F src/util.c 10572efe1bcf43fc2f6015cfba6126a4a5e32e7d6478a946a2b27d5ce189328b
+F src/util.c 72874125f70f61082bfb82b4580c1a320ab22b8cded2fb98e42ab98b39dc7bf1
 F src/vacuum.c d3d35d8ae893d419ade5fa196d761a83bddcbb62137a1a157ae751ef38b26e82
 F src/vdbe.c 5328c99dd256ee8132383565a86e253543a85daccfd7477c52f20bac6b385a7f
 F src/vdbe.h 966d0677a540b7ea6549b7c4e1312fc0d830fce3a235a58c801f2cc31cf5ecf9
@@ -2194,8 +2194,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 091bd90ed5a6a326fd532e93bd17903e052476da14dc6aee2599a9acf75a3276
-R cd671e340350caab6a75edc7dcce7710
+P f3cc05ba7fa9cb77573de5cd28ab90f10844567692ed57a706c5dc35b1348009
+R c76121d106ccfa4ba10f05ce6b9cda5e
 U drh
-Z af08287ac982b3bc21237452366bd06d
+Z d2d61bfcd3046306c59cf37d2f198b36
 # Remove this line to create a well-formed Fossil manifest.
index 339f48cea9549cfba6978fac1628ab7632ccdbb8..c26f9fb5b4ca437e3b6e327e27d585bc5c7f38af 100644 (file)
@@ -1 +1 @@
-f3cc05ba7fa9cb77573de5cd28ab90f10844567692ed57a706c5dc35b1348009
+e540f6c370675ae043af8cdbb80f7eb17c08e50f7634e0b78f0b1dccf7bd4b18
index ebd38705c20fc071702c0b410e6615ad5a0ae343..048db497c2a0b641766e06da422e53453f6b662e 100644 (file)
@@ -648,13 +648,12 @@ static int countLeadingZeros(u64 m){
 */
 static void sqlite3Fp2Convert10(u64 m, int e, int n, u64 *pD, int *pP){
   int p;
-  u64 h, out;
+  u64 h;
   p = n - 1 - pwr2to10(e+63);
   h = sqlite3Multiply128(m, powerOfTen(p));
-  assert( -(e + pwr10to2(p) + 3) >=0 );
-  assert( -(e + pwr10to2(p) + 3) <64 );
-  out = h >> -(e + pwr10to2(p) + 3);
-  *pD = (out + 2 + ((out>>2)&1)) >> 2;
+  assert( -(e + pwr10to2(p) + 1) >=0 );
+  assert( -(e + pwr10to2(p) + 1) <64 );
+  *pD = h >> -(e + pwr10to2(p) + 1);
   *pP = -p;
 }
 
@@ -1156,7 +1155,7 @@ int sqlite3Atoi(const char *z){
 ** representation.
 **
 ** If iRound<=0 then round to -iRound significant digits to the
-** the left of the decimal point, or to a maximum of mxRound total
+** the right of the decimal point, or to a maximum of mxRound total
 ** significant digits.
 **
 ** If iRound>0 round to min(iRound,mxRound) significant digits total.
@@ -1208,7 +1207,7 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){
     v = (v<<11) | U64_BIT(63);
     e -= 1086;
   }
-  sqlite3Fp2Convert10(v, e, 17, &v, &exp);  
+  sqlite3Fp2Convert10(v, e, (iRound<=0||iRound>=18)?18:iRound+1, &v, &exp);  
 
   /* Extract significant digits. */
   i = sizeof(p->zBuf)-1;