Lines Matching refs:df
214 /* df is the decFloat format number which gets the final result */
218 /* returns df */
242 static decFloat * decFinalize(decFloat *df, bcdnum *num,
495 return decFloatFromBCD(df, num->exponent, umsd, num->sign);
525 /* place the declets in the encoding words and copy to result (df), */
533 DFWORD(df, 0)=encode; /* just the one word */
538 DFWORD(df, 0)=encode;
543 DFWORD(df, 1)=encode;
548 DFWORD(df, 0)=encode;
554 DFWORD(df, 1)=encode;
560 DFWORD(df, 2)=encode;
566 DFWORD(df, 3)=encode;
570 /* decFloatShow(df, "final2"); */
571 return df;
577 /* df is the target decFloat */
582 /* if df is a NaN; all are ignored if df is infinite. */
585 /* returns df, which will be canonical */
589 decFloat * decFloatFromBCD(decFloat *df, Int exp, const uByte *bcdar,
613 /* place the declets in the encoding words and copy to result (df), */
621 DFWORD(df, 0)=encode; /* just the one word */
626 DFWORD(df, 0)=encode;
631 DFWORD(df, 1)=encode;
636 DFWORD(df, 0)=encode;
642 DFWORD(df, 1)=encode;
648 DFWORD(df, 2)=encode;
654 DFWORD(df, 3)=encode;
656 /* decFloatShow(df, "fromB"); */
657 return df;
663 /* df is the target decFloat */
667 /* (all 6 codes are OK); the first (MSD) is ignored if df is a NaN */
668 /* and all except sign are ignored if df is infinite. For DOUBLE */
672 /* returns df, which will be canonical */
676 decFloat * decFloatFromPacked(decFloat *df, Int exp, const uByte *packed) {
699 return decFloatFromBCD(df, exp, bcdar+1, sig);
705 /* df is the target decFloat */
709 /* (all 6 codes are OK); the first (MSD) must be 0 if df is a NaN */
710 /* and all digits must be 0 if df is infinite. For DOUBLE and */
713 /* returns df, which will be canonical or NULL if any of the */
714 /* requirements are not met (if this case df is unchanged); that */
720 decFloat * decFloatFromPackedChecked(decFloat *df, Int exp,
763 return decFloatFromBCD(df, exp, bcdar+1, sig);
1060 /* df is the decFloat from which to extract the coefficient */
1062 /* each byte (BCD8 encoding); if df is a NaN the first byte will */
1067 /* No error is possible, and no status will be set. If df is a */
1071 Int decFloatGetCoefficient(const decFloat *df, uByte *bcdar) {
1072 if (DFISINF(df)) memset(bcdar, 0, DECPMAX);
1074 GETCOEFF(df, bcdar); /* use macro */
1075 if (DFISNAN(df)) bcdar[0]=0; /* MSD needs correcting */
1077 return DFISSIGNED(df);
1083 /* df is the decFloat from which to extract the exponent */
1086 /* No error is possible, and no status will be set. If df is a */
1091 Int decFloatGetExponent(const decFloat *df) {
1092 if (DFISSPECIAL(df)) return DFWORD(df, 0)&0x7e000000;
1093 return GETEXPUN(df);
1099 /* df is the target decFloat (and source of exponent/special value) */
1102 /* if df is a NaN; all are ignored if df is infinite. */
1104 /* returns df, which will be canonical */
1108 decFloat * decFloatSetCoefficient(decFloat *df, const uByte *bcdar,
1113 /* Exponent/special code is extracted from df */
1114 if (DFISSPECIAL(df)) {
1115 exp=DFWORD(df, 0)&0x7e000000;
1116 if (DFISINF(df)) {
1118 return decFloatFromBCD(df, exp, bcdzero, sig);
1121 else exp=GETEXPUN(df);
1122 return decFloatFromBCD(df, exp, bcdar, sig);
1128 /* df is the target decFloat (and source of coefficient/payload) */
1132 /* returns df, which will be canonical */
1136 decFloat * decFloatSetExponent(decFloat *df, decContext *set, Int exp) {
1140 num.sign=decFloatGetCoefficient(df, bcdcopy); /* extract coefficient */
1141 if (DFISSPECIAL(df)) { /* MSD or more needs correcting */
1142 if (DFISINF(df)) memset(bcdcopy, 0, DECPMAX);
1147 return decFinalize(df, &num, set);
1153 /* df is any decFloat of this format */
1155 uInt decFloatRadix(const decFloat *df) {
1156 if (df) return 10; /* to placate compiler */
1163 /* df is the decFloat to show */
1168 void decFloatShow(const decFloat *df, const char *tag) {
1175 sprintf(&hexbuf[j], "%02x", df->bytes[DECBYTES-1-i]);
1177 sprintf(&hexbuf[j], "%02x", df->bytes[i]);
1183 decFloatToString(df, buff);
1192 /* df is the source decFloat */
1196 /* each byte (BCD8 encoding); if df is a NaN the first byte will */
1203 Int decFloatToBCD(const decFloat *df, Int *exp, uByte *bcdar) {
1204 if (DFISINF(df)) {
1206 *exp=DFWORD(df, 0)&0x7e000000;
1209 GETCOEFF(df, bcdar); /* use macro */
1210 if (DFISNAN(df)) {
1212 *exp=DFWORD(df, 0)&0x7e000000;
1215 *exp=GETEXPUN(df);
1218 return DFISSIGNED(df);
1224 /* df is the decFloat format number to convert */
1233 char * decFloatToEngString(const decFloat *df, char *string){
1247 uInt sourhi=DFWORD(df, 0); /* word with sign */
1249 uInt sourlo=DFWORD(df, 1);
1251 uInt sourmh=DFWORD(df, 1);
1252 uInt sourml=DFWORD(df, 2);
1253 uInt sourlo=DFWORD(df, 3);
1284 exp+=GETECON(df)-DECBIAS; /* .. + continuation and unbias */
1361 if (!DFISZERO(df)) pre+=adj;
1455 /* df is the source decFloat */
1468 Int decFloatToPacked(const decFloat *df, Int *exp, uByte *packed) {
1471 if (DFISINF(df)) {
1476 GETCOEFF(df, bcdar+1); /* use macro */
1477 if (DFISNAN(df)) {
1479 *exp=DFWORD(df, 0)&0x7e000000;
1482 *exp=GETEXPUN(df);
1492 bcdar[DECPMAX+1]=(DFISSIGNED(df) ? DECPMINUS : DECPPLUS);
1503 /* df is the decFloat format number to convert */
1512 char * decFloatToString(const decFloat *df, char *string){
1526 uInt sourhi=DFWORD(df, 0); /* word with sign */
1528 uInt sourlo=DFWORD(df, 1);
1530 uInt sourmh=DFWORD(df, 1);
1531 uInt sourml=DFWORD(df, 2);
1532 uInt sourlo=DFWORD(df, 3);
1543 exp+=GETECON(df)-DECBIAS; /* .. + continuation and unbias */
1767 /* df is the decFloat format number to integer +0 (q=0, c=+0) */
1768 /* returns df */
1772 decFloat * decFloatZero(decFloat *df){
1773 DFWORD(df, 0)=ZEROWORD; /* set appropriate top word */
1775 DFWORD(df, 1)=0;
1777 DFWORD(df, 2)=0;
1778 DFWORD(df, 3)=0;
1781 /* decFloatShow(df, "zero"); */
1782 return df;