------------------------------------------------------------------ */ decFloatSetExponent -- set exponent or special value */ / df is the target decFloat (and source of coefficient/payload) */ set is the context for reporting status */ exp is the unbiased exponent, q, or a special value in the form */ returned by decFloatGetExponent
| 1125 | /* No error is possible, but Overflow or Underflow might occur. */ |
| 1126 | /* ------------------------------------------------------------------ */ |
| 1127 | decFloat * decFloatSetExponent(decFloat *df, decContext *set, Int exp) { |
| 1128 | uByte bcdcopy[DECPMAX]; // for coefficient |
| 1129 | bcdnum num; // work |
| 1130 | num.exponent=exp; |
| 1131 | num.sign=decFloatGetCoefficient(df, bcdcopy); // extract coefficient |
| 1132 | if (DFISSPECIAL(df)) { // MSD or more needs correcting |
| 1133 | if (DFISINF(df)) memset(bcdcopy, 0, DECPMAX); |
| 1134 | bcdcopy[0]=0; |
| 1135 | } |
| 1136 | num.msd=bcdcopy; |
| 1137 | num.lsd=bcdcopy+DECPMAX-1; |
| 1138 | return decFinalize(df, &num, set); |
| 1139 | } // decFloatSetExponent |
| 1140 | |
| 1141 | /* ------------------------------------------------------------------ */ |
| 1142 | /* decFloatRadix -- returns the base (10) */ |
no test coverage detected