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

Function decimal2ulonglong

strings/decimal.c:1036–1063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1034}
1035
1036int decimal2ulonglong(decimal_t *from, ulonglong *to)
1037{
1038 dec1 *buf=from->buf;
1039 ulonglong x=0;
1040 int intg, frac;
1041
1042 if (from->sign)
1043 {
1044 *to=ULL(0);
1045 return E_DEC_OVERFLOW;
1046 }
1047
1048 for (intg=from->intg; intg > 0; intg-=DIG_PER_DEC1)
1049 {
1050 ulonglong y=x;
1051 x=x*DIG_BASE + *buf++;
1052 if (unlikely(y > ((ulonglong) ULONGLONG_MAX/DIG_BASE) || x < y))
1053 {
1054 *to=ULONGLONG_MAX;
1055 return E_DEC_OVERFLOW;
1056 }
1057 }
1058 *to=x;
1059 for (frac=from->frac; unlikely(frac > 0); frac-=DIG_PER_DEC1)
1060 if (*buf++)
1061 return E_DEC_TRUNCATED;
1062 return E_DEC_OK;
1063}
1064
1065int decimal2longlong(decimal_t *from, longlong *to)
1066{

Callers 1

my_decimal2intFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected