1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-22 22:13:04 +03:00

Use the log10() and log2() functions from the standard C library to implement

the equivalent SQL functions, in the hope that this will prevent reported
precision problems.
See [forum:/forumpost/cfceb1230bdcfd84|forum post cfceb1230bdcfd84] and the
surrounding thread.

FossilOrigin-Name: 7c572d02e60a83b36543ba4d9d45f61e9fc111b61fee085410c2d87558c732d6
This commit is contained in:
drh
2022-11-17 14:40:33 +00:00
parent 823872c6d6
commit 3c1572ddb4
3 changed files with 10 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
C Split\sout\sthe\sdocumentation\sfor\ssqlite3_value_encoding()\sinto\sits\sown\npage\sand\smake\sit\sclear\sthat\sthis\sinterface\sis\sintended\sfor\stesting\sand\ndebugging\sonly.\n[forum:/forumpost/c9f445453da950ad|Forum\sthread\sc9f445453da950ad].\nComment\schanges\sonly\s-\sno\schanges\sto\scode.
D 2022-11-17T13:58:25.001
C Use\sthe\slog10()\sand\slog2()\sfunctions\sfrom\sthe\sstandard\sC\slibrary\sto\simplement\nthe\sequivalent\sSQL\sfunctions,\sin\sthe\shope\sthat\sthis\swill\sprevent\sreported\nprecision\sproblems.\nSee\s[forum:/forumpost/cfceb1230bdcfd84|forum\spost\scfceb1230bdcfd84]\sand\sthe\nsurrounding\sthread.
D 2022-11-17T14:40:33.537
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -590,7 +590,7 @@ F src/delete.c 86573edae75e3d3e9a8b590d87db8e47222103029df4f3e11fa56044459b514e
F src/expr.c 847f87d9df3ede2b2b0a8db088af0b9c1923b21009f8ea1b9b7b28cb0a383170
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 722f20779f5342a787922deded3628d8c74b5249cab04098cf17ee2f2aaff002
F src/func.c d25f3c667d59dbac195e65f3539fdbbd8a36c142ce7bcdb45d1baf07446ad13a
F src/func.c 7e86074afc4dc702691a29b7801f6dcc191db092b52e8bbe69dcd2f7be52194d
F src/global.c e06ff8e0acd85aec13563c9ecb44fbbf38232ccf73594998fd880b92d619594b
F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19
F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
@@ -2055,8 +2055,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P a119a9e2ade4eac5feb1aa885c15b83e725f87386351de99d3abb49656219d50
R b081909c6ecb1750561be5091dea8e63
P 9048a766ff7dfa0cd91ea74092e462f4501cb3f719033ccb55700bf5e4dfd0d3
R a034e1e03397012452b518f4075f2764
U drh
Z c8051a67682b7cc2de89c2c47da25213
Z 49084f227abbaddd45e0c2d870d50ee7
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
9048a766ff7dfa0cd91ea74092e462f4501cb3f719033ccb55700bf5e4dfd0d3
7c572d02e60a83b36543ba4d9d45f61e9fc111b61fee085410c2d87558c732d6

View File

@@ -2106,17 +2106,15 @@ static void logFunc(
}
ans = log(x)/b;
}else{
ans = log(x);
switch( SQLITE_PTR_TO_INT(sqlite3_user_data(context)) ){
case 1:
/* Convert from natural logarithm to log base 10 */
ans /= M_LN10;
ans = log10(x);
break;
case 2:
/* Convert from natural logarithm to log base 2 */
ans /= M_LN2;
ans = log2(x);
break;
default:
ans = log(x);
break;
}
}