Skip to content

Commit

Permalink
ull2dec: exact calculation of the precision
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Jun 30, 2016
1 parent 4dcbb77 commit da372fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions mysql-test/r/bigint.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions mysql-test/r/dyncol.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions strings/decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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--)
{
Expand Down

0 comments on commit da372fb

Please sign in to comment.