mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
ull2dec: exact calculation of the precision
This commit is contained in:
@ -385,7 +385,7 @@ def -((9223372036854775808)) 8 20 20 N 32897 0 63
|
||||
-9223372036854775808
|
||||
select -(-(9223372036854775808));
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def -(-(9223372036854775808)) 246 21 19 N 32897 0 63
|
||||
def -(-(9223372036854775808)) 246 20 19 N 32897 0 63
|
||||
-(-(9223372036854775808))
|
||||
9223372036854775808
|
||||
select --9223372036854775808, ---9223372036854775808, ----9223372036854775808;
|
||||
@ -402,7 +402,7 @@ drop table t1;
|
||||
create table t1 select -9223372036854775809 bi;
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
bi decimal(20,0) NO NULL
|
||||
bi decimal(19,0) NO NULL
|
||||
drop table t1;
|
||||
#
|
||||
# Bug #45360: wrong results
|
||||
|
@ -91,19 +91,19 @@ hex(COLUMN_CREATE(1, NULL AS decimal))
|
||||
000000
|
||||
select hex(COLUMN_CREATE(1, 1212 AS decimal));
|
||||
hex(COLUMN_CREATE(1, 1212 AS decimal))
|
||||
0001000100040900800004BC
|
||||
000100010004040084BC
|
||||
select hex(COLUMN_CREATE(1, 7 AS decimal));
|
||||
hex(COLUMN_CREATE(1, 7 AS decimal))
|
||||
000100010004090080000007
|
||||
000100010004010087
|
||||
select hex(COLUMN_CREATE(1, 8 AS decimal));
|
||||
hex(COLUMN_CREATE(1, 8 AS decimal))
|
||||
000100010004090080000008
|
||||
000100010004010088
|
||||
select hex(COLUMN_CREATE(1, 127 AS decimal));
|
||||
hex(COLUMN_CREATE(1, 127 AS decimal))
|
||||
00010001000409008000007F
|
||||
0001000100040300807F
|
||||
select hex(COLUMN_CREATE(1, 128 AS decimal));
|
||||
hex(COLUMN_CREATE(1, 128 AS decimal))
|
||||
000100010004090080000080
|
||||
00010001000403008080
|
||||
select hex(COLUMN_CREATE(1, 12.12 AS decimal));
|
||||
hex(COLUMN_CREATE(1, 12.12 AS decimal))
|
||||
00010001000402028C0C
|
||||
|
@ -1005,8 +1005,7 @@ static int ull2dec(ulonglong from, decimal_t *to)
|
||||
error=E_DEC_OVERFLOW;
|
||||
}
|
||||
to->frac=0;
|
||||
/* intg can't be bigger than number of digits in a ulonglong (20) */
|
||||
to->intg= MY_MIN(intg1*DIG_PER_DEC1, 20);
|
||||
for(to->intg= (intg1-1)*DIG_PER_DEC1; from; to->intg++, from/=10) {}
|
||||
|
||||
for (buf=to->buf+intg1; intg1; intg1--)
|
||||
{
|
||||
|
Reference in New Issue
Block a user