diff options
author | drh <> | 2023-06-30 18:35:43 +0000 |
---|---|---|
committer | drh <> | 2023-06-30 18:35:43 +0000 |
commit | a1b0ff173520fc73a182e57b06b1d0228b343711 (patch) | |
tree | 5f2283b7e1e6d2e93076869fcdd955104256862c /src/func.c | |
parent | 24b368da8dac15cb7d3997ae4fa27d76f0fc682a (diff) | |
download | sqlite-a1b0ff173520fc73a182e57b06b1d0228b343711.tar.gz sqlite-a1b0ff173520fc73a182e57b06b1d0228b343711.zip |
Experiments with a new algorithm for converting ieee-754 binary64 numbers
into decimal.
FossilOrigin-Name: e923405e448385085224f9289991b303d86b02763535ea77d6fcee98ba6fc1f2
Diffstat (limited to 'src/func.c')
-rw-r--r-- | src/func.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/func.c b/src/func.c index b24359186..4cf930b20 100644 --- a/src/func.c +++ b/src/func.c @@ -2371,6 +2371,23 @@ static void signFunc( sqlite3_result_int(context, x<0.0 ? -1 : x>0.0 ? +1 : 0); } + +#if 1 /* Temporary prototyping logic */ +static void fpdecodeFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + double r = sqlite3_value_double(argv[0]); + FpDecode s; + char zBuf[50]; + UNUSED_PARAMETER(argc); + sqlite3FpDecode(&s, r); + sqlite3_snprintf(sizeof(zBuf), zBuf, "%c%.*s/%d", s.sign, s.n, s.z, s.iDP); + sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); +} +#endif /* Temporary prototyping logic */ + /* ** All of the FuncDef structures in the aBuiltinFunc[] array above ** to the global function hash table. This occurs at start-time (as @@ -2442,6 +2459,11 @@ void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(unicode, 1, 0, 0, unicodeFunc ), FUNCTION(char, -1, 0, 0, charFunc ), FUNCTION(abs, 1, 0, 0, absFunc ), + +#if 1 /* Temporary prototyping function */ + FUNCTION(fpdecode, 1, 0, 0, fpdecodeFunc ), +#endif + #ifndef SQLITE_OMIT_FLOATING_POINT FUNCTION(round, 1, 0, 0, roundFunc ), FUNCTION(round, 2, 0, 0, roundFunc ), |