| 995 | |
| 996 | |
| 997 | static 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 | |
| 1023 | int ulonglong2decimal(ulonglong from, decimal_t *to) |
| 1024 | { |
no outgoing calls
no test coverage detected