------------------------------------------------------------------ */ decFloatFromPacked -- set decFloat from exponent and packed BCD */ / df is the target decFloat */ exp is the in-range unbiased exponent, q, or a special value in */ the form returned by decFloatGetExponent */ packed holds DECPMAX packed decimal digits plus a sig
| 662 | /* No error is possible, and no status will be set. */ |
| 663 | /* ------------------------------------------------------------------ */ |
| 664 | decFloat * decFloatFromPacked(decFloat *df, Int exp, const uByte *packed) { |
| 665 | uByte bcdar[DECPMAX+2]; // work [+1 for pad, +1 for sign] |
| 666 | const uByte *ip; // .. |
| 667 | uByte *op; // .. |
| 668 | Int sig=0; // sign |
| 669 | |
| 670 | // expand coefficient and sign to BCDAR |
| 671 | #if SINGLE |
| 672 | op=bcdar+1; // no pad digit |
| 673 | #else |
| 674 | op=bcdar; // first (pad) digit ignored |
| 675 | #endif |
| 676 | for (ip=packed; ip<packed+((DECPMAX+2)/2); ip++) { |
| 677 | *op++=*ip>>4; |
| 678 | *op++=(uByte)(*ip&0x0f); // [final nibble is sign] |
| 679 | } |
| 680 | op--; // -> sign byte |
| 681 | if (*op==DECPMINUS || *op==DECPMINUSALT) sig=DECFLOAT_Sign; |
| 682 | |
| 683 | if (EXPISSPECIAL(exp)) { // Infinity or NaN |
| 684 | if (!EXPISINF(exp)) bcdar[1]=0; // a NaN: ignore MSD |
| 685 | else memset(bcdar+1, 0, DECPMAX); // Infinite: coefficient to 0 |
| 686 | } |
| 687 | return decFloatFromBCD(df, exp, bcdar+1, sig); |
| 688 | } // decFloatFromPacked |
| 689 | |
| 690 | /* ------------------------------------------------------------------ */ |
| 691 | /* decFloatFromPackedChecked -- set from exponent and packed; checked */ |
nothing calls this directly
no test coverage detected