MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / do_mini_right_shift

Function do_mini_right_shift

strings/decimal.c:554–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552*/
553
554void do_mini_right_shift(decimal_t *dec, int shift, int beg, int last)
555{
556 dec1 *from= dec->buf + ROUND_UP(last) - 1;
557 dec1 *end= dec->buf + ROUND_UP(beg + 1) - 1;
558 int c_shift= DIG_PER_DEC1 - shift;
559 DBUG_ASSERT(from < dec->buf + dec->len);
560 DBUG_ASSERT(end >= dec->buf);
561 if (DIG_PER_DEC1 - ((last - 1) % DIG_PER_DEC1 + 1) < shift)
562 *(from + 1)= (*from % powers10[shift]) * powers10[c_shift];
563 for(; from > end; from--)
564 *from= (*from / powers10[shift] +
565 (*(from - 1) % powers10[shift]) * powers10[c_shift]);
566 *from= *from / powers10[shift];
567}
568
569
570/*

Callers 1

decimal_shiftFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected