SQLite

Check-in [7c572d02]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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 post cfceb1230bdcfd84 and the surrounding thread.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7c572d02e60a83b36543ba4d9d45f61e9fc111b61fee085410c2d87558c732d6
User & Date: drh 2022-11-17 14:40:33
Context
2022-11-17
19:24
Fix corner cases in UTF8 handling in the REGEXP extension. Forum post 3ffe058b04. (check-in: abb18f61 user: drh tags: trunk)
15:21
Merge trunk into js-cpp branch. (check-in: e047b33d user: stephan tags: js-cpp)
14:40
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 post cfceb1230bdcfd84 and the surrounding thread. (check-in: 7c572d02 user: drh tags: trunk)
13:58
Split out the documentation for sqlite3_value_encoding() into its own page and make it clear that this interface is intended for testing and debugging only. Forum thread c9f445453da950ad. Comment changes only - no changes to code. (check-in: 9048a766 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/func.c.
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119

2120
2121
2122
2123
2124
2125
2126
        if( x<=0.0 ) return;
        break;
     default:
        return;
    }
    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;
        break;
      case 2:
        /* Convert from natural logarithm to log base 2 */
        ans /= M_LN2;
        break;
      default:

        break;
    }
  }
  sqlite3_result_double(context, ans);
}

/*







<


<
|


<
|


>







2102
2103
2104
2105
2106
2107
2108

2109
2110

2111
2112
2113

2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
        if( x<=0.0 ) return;
        break;
     default:
        return;
    }
    ans = log(x)/b;
  }else{

    switch( SQLITE_PTR_TO_INT(sqlite3_user_data(context)) ){
      case 1:

        ans = log10(x);
        break;
      case 2:

        ans = log2(x);
        break;
      default:
        ans = log(x);
        break;
    }
  }
  sqlite3_result_double(context, ans);
}

/*