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

Function ull2dec

strings/decimal.c:997–1021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

995
996
997static int ull2dec(ulonglong from, decimal_t *to)
998{
999 int intg1, error=E_DEC_OK;
1000 ulonglong x=from;
1001 dec1 *buf;
1002
1003 sanity(to);
1004
1005 for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE) ;
1006 if (unlikely(intg1 > to->len))
1007 {
1008 intg1=to->len;
1009 error=E_DEC_OVERFLOW;
1010 }
1011 to->frac=0;
1012 to->intg=intg1*DIG_PER_DEC1;
1013
1014 for (buf=to->buf+intg1; intg1; intg1--)
1015 {
1016 ulonglong y=x/DIG_BASE;
1017 *--buf=(dec1)(x-y*DIG_BASE);
1018 x=y;
1019 }
1020 return error;
1021}
1022
1023int ulonglong2decimal(ulonglong from, decimal_t *to)
1024{

Callers 2

ulonglong2decimalFunction · 0.85
longlong2decimalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected