1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-21 11:13:54 +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

@@ -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;
}
}