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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user