| 403 | } // decNumberToInt32 |
| 404 | |
| 405 | uInt decNumberToUInt32(const decNumber *dn, decContext *set) { |
| 406 | #if DECCHECK |
| 407 | if (decCheckOperands(DECUNRESU, DECUNUSED, dn, set)) return 0; |
| 408 | #endif |
| 409 | // special or too many digits, or bad exponent, or negative (<0) |
| 410 | if (dn->bits&DECSPECIAL || dn->digits>10 || dn->exponent!=0 |
| 411 | || (dn->bits&DECNEG && !ISZERO(dn))); // bad |
| 412 | else { // is a finite integer with 10 or fewer digits |
| 413 | Int d; // work |
| 414 | const Unit *up; // .. |
| 415 | uInt hi=0, lo; // .. |
| 416 | up=dn->lsu; // -> lsu |
| 417 | lo=*up; // get 1 to 9 digits |
| 418 | #if DECDPUN>1 // split to higher |
| 419 | hi=lo/10; |
| 420 | lo=lo%10; |
| 421 | #endif |
| 422 | up++; |
| 423 | // collect remaining Units, if any, into hi |
| 424 | for (d=DECDPUN; d<dn->digits; up++, d+=DECDPUN) hi+=*up*powers[d-1]; |
| 425 | |
| 426 | // now low has the lsd, hi the remainder |
| 427 | if (hi>429496729 || (hi==429496729 && lo>5)) ; // no reprieve possible |
| 428 | else return X10(hi)+lo; |
| 429 | } // integer |
| 430 | decContextSetStatus(set, DEC_Invalid_operation); // [may not return] |
| 431 | return 0; |
| 432 | } // decNumberToUInt32 |
| 433 | |
| 434 | /* ------------------------------------------------------------------ */ |
| 435 | /* to-scientific-string -- conversion to numeric string */ |
nothing calls this directly
no test coverage detected