mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Enhancements to the DECIMAL extension:
(1) If the argument to decimal(X) is a floating point value (or an 8-byte blob), the floating point value is expanded into its exact decimal representation. (2) Function decimal_sci(X) works the same except it returns the result in scientific notation. (3) New function decimal_pow2(N) returns the full decimal expansion of the N-th integer power of 2. FossilOrigin-Name: 8baf8c10aecb261751f2b154356ab224b79d07230929ec9f123791278e601bba
This commit is contained in:
@ -23,31 +23,34 @@ do_execsql_test 1000 {
|
||||
SELECT decimal(1);
|
||||
} {1}
|
||||
do_execsql_test 1010 {
|
||||
SELECT decimal(1.0);
|
||||
SELECT decimal('1.0');
|
||||
} {1.0}
|
||||
do_execsql_test 1020 {
|
||||
SELECT decimal(0001.0);
|
||||
SELECT decimal('0001.0');
|
||||
} {1.0}
|
||||
do_execsql_test 1030 {
|
||||
SELECT decimal(+0001.0);
|
||||
SELECT decimal('+0001.0');
|
||||
} {1.0}
|
||||
do_execsql_test 1040 {
|
||||
SELECT decimal(-0001.0);
|
||||
SELECT decimal('-0001.0');
|
||||
} {-1.0}
|
||||
do_execsql_test 1050 {
|
||||
SELECT decimal(1.0e72);
|
||||
SELECT decimal('1.0e72');
|
||||
} {1000000000000000000000000000000000000000000000000000000000000000000000000}
|
||||
# 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123
|
||||
do_execsql_test 1060 {
|
||||
SELECT decimal(1.0e-72);
|
||||
SELECT decimal('1.0e-72');
|
||||
} {0.0000000000000000000000000000000000000000000000000000000000000000000000010}
|
||||
# 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123
|
||||
do_execsql_test 1070 {
|
||||
SELECT decimal(-123e-4);
|
||||
SELECT decimal('-123e-4');
|
||||
} {-0.0123}
|
||||
do_execsql_test 1080 {
|
||||
SELECT decimal(+123e+4);
|
||||
} {1230000.0}
|
||||
SELECT decimal('+123e+4');
|
||||
} {1230000}
|
||||
do_execsql_test 1081 {
|
||||
SELECT decimal_sci('+123e+4');
|
||||
} {+1.23e+06}
|
||||
|
||||
|
||||
do_execsql_test 2000 {
|
||||
@ -161,6 +164,10 @@ do_execsql_test 6010 {
|
||||
SELECT decimal_mul(ieee754_mantissa(c.n),pow2.v)
|
||||
FROM pow2, c WHERE pow2.x=ieee754_exponent(c.n);
|
||||
} {0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625}
|
||||
do_execsql_test 6011 {
|
||||
WITH c(n) AS (SELECT ieee754_from_blob(x'0000000000000001'))
|
||||
SELECT decimal(c.n) FROM c;
|
||||
} {0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625}
|
||||
do_execsql_test 6020 {
|
||||
WITH c(n) AS (SELECT ieee754_from_blob(x'7fefffffffffffff'))
|
||||
SELECT decimal_mul(ieee754_mantissa(c.n),pow2.v)
|
||||
|
Reference in New Issue
Block a user