------------------------------------------------------------------ */ decDecap -- decapitate the coefficient of a number */ / dn is the number to be decapitated */ drop is the number of digits to be removed from the left of dn; */ this must be <= dn->digits (if equal, the coefficient is */ set to 0)
| 7627 | /* which will also be removed). Only dn->lsu and dn->digits change. */ |
| 7628 | /* ------------------------------------------------------------------ */ |
| 7629 | static decNumber *decDecap(decNumber *dn, Int drop) { |
| 7630 | Unit *msu; // -> target cut point |
| 7631 | Int cut; // work |
| 7632 | if (drop>=dn->digits) { // losing the whole thing |
| 7633 | #if DECCHECK |
| 7634 | if (drop>dn->digits) |
| 7635 | printf("decDecap called with drop>digits [%ld>%ld]\n", |
| 7636 | (LI)drop, (LI)dn->digits); |
| 7637 | #endif |
| 7638 | dn->lsu[0]=0; |
| 7639 | dn->digits=1; |
| 7640 | return dn; |
| 7641 | } |
| 7642 | msu=dn->lsu+D2U(dn->digits-drop)-1; // -> likely msu |
| 7643 | cut=MSUDIGITS(dn->digits-drop); // digits to be in use in msu |
| 7644 | if (cut!=DECDPUN) *msu%=powers[cut]; // clear left digits |
| 7645 | // that may have left leading zero digits, so do a proper count... |
| 7646 | dn->digits=decGetDigits(dn->lsu, msu-dn->lsu+1); |
| 7647 | return dn; |
| 7648 | } // decDecap |
| 7649 | |
| 7650 | /* ------------------------------------------------------------------ */ |
| 7651 | /* decBiStr -- compare string with pairwise options */ |
no test coverage detected