Commit 6044f5e3 by Sylvestre Ledru Committed by Jeff Law

bid2dpd_dpd2bid.c (_bid_to_dpd32): Fix whitespace.

	* bid/bid2dpd_dpd2bid.c (_bid_to_dpd32): Fix whitespace.
	(_dpd_to_bid32): Simplify identical code on multiple branches.
	Fix whitespace.
	(_bid_to_dpd64, _dpd_to_bid64): Likewise.
	(_bid_to_dpd128, _dpd_to_bid128): Likewise.

From-SVN: r249803
parent e9d22c8a
2017-05-29 Sylvestre Ledru <sylvestre@debian.org>
* bid/bid2dpd_dpd2bid.c (_bid_to_dpd32): Fix whitespace.
(_dpd_to_bid32): Simplify identical code on multiple branches.
Fix whitespace.
(_bid_to_dpd64, _dpd_to_bid64): Likewise.
(_bid_to_dpd128, _dpd_to_bid128): Likewise.
2017-04-03 Jonathan Wakely <jwakely@redhat.com>
* decCommon.c (decFloatFromPackedChecked): Fix typo in comment.
......
......@@ -138,7 +138,8 @@ _dpd_to_bid32 (_Decimal32 *pres, _Decimal32 *px) {
if ((x & 0x78000000) == 0x78000000) {
*pres = x;
return;
} else { /* normal number */
}
/* normal number */
if ((x & 0x60000000) == 0x60000000) { /* G0..G1 = 11 -> d0 = 8 + G4 */
d0 = d2b3[((x >> 26) & 1) | 8]; /* d0 = (comb & 0x0100 ? 9 : 8); */
exp = (x >> 27) & 3; /* exp leading bits are G2..G3 */
......@@ -161,7 +162,6 @@ _dpd_to_bid32 (_Decimal32 *pres, _Decimal32 *px) {
/* add coeff, without leading bits */
r |= (((unsigned int) bcoeff) & 0x1fffff);
}
}
*pres = r;
}
......@@ -184,7 +184,8 @@ _bid_to_dpd64 (_Decimal64 *pres, _Decimal64 *px) {
if ((comb & 0xf00) == 0xf00) {
*pres = x;
return;
} else { /* Normal number */
}
/* Normal number */
if ((comb & 0xc00) == 0xc00) { /* G0..G1 = 11 -> exp is G2..G11 */
exp = (comb) & 0x3ff;
bcoeff = (x & 0x0007ffffffffffffull) | 0x0020000000000000ull;
......@@ -217,7 +218,6 @@ _bid_to_dpd64 (_Decimal64 *pres, _Decimal64 *px) {
else /* else b0 is 0..7 */
res = sign | ((((exp >> 8) << 11) | (b0 << 8) |
(exp & 0xff)) << 50) | dcoeff;
}
*pres = res;
}
......@@ -237,17 +237,10 @@ _dpd_to_bid64 (_Decimal64 *pres, _Decimal64 *px) {
comb = (x & 0x7ffc000000000000ull) >> 50;
trailing = (x & 0x0003ffffffffffffull);
if ((comb & 0x1e00) == 0x1e00) {
if ((comb & 0x1f00) == 0x1f00) { /* G0..G4 = 11111 -> NaN */
if (comb & 0x0100) { /* G5 = 1 -> sNaN */
*pres = x;
} else { /* G5 = 0 -> qNaN */
*pres = x;
}
} else { /*if ((comb & 0x1e00) == 0x1e00); G0..G4 = 11110 -> INF */
*pres = x;
}
return;
} else { /* normal number */
}
/* normal number */
if ((comb & 0x1800) == 0x1800) { /* G0..G1 = 11 -> d0 = 8 + G4 */
d0 = d2b6[((comb >> 8) & 1) | 8]; /* d0 = (comb & 0x0100 ? 9 : 8); */
exp = (comb & 0x600) >> 1; /* exp = (comb & 0x0400 ? 1 : 0) * 0x200 +
......@@ -279,7 +272,6 @@ _dpd_to_bid64 (_Decimal64 *pres, _Decimal64 *px) {
mask = (mask >> 2) - 1;
bcoeff &= mask;
res |= bcoeff;
}
*pres = res;
}
......@@ -304,15 +296,7 @@ _bid_to_dpd128 (_Decimal128 *pres, _Decimal128 *px) {
comb = (x.w[1] /*& 0x7fffc00000000000ull */ ) >> 46;
exp = 0;
if ((comb & 0x1e000) == 0x1e000) {
if ((comb & 0x1f000) == 0x1f000) { /* G0..G4 = 11111 -> NaN */
if (comb & 0x01000) { /* G5 = 1 -> sNaN */
res = x;
} else { /* G5 = 0 -> qNaN */
res = x;
}
} else { /* G0..G4 = 11110 -> INF */
res = x;
}
} else { /* normal number */
exp = ((x.w[1] & 0x7fff000000000000ull) >> 49) & 0x3fff;
bcoeff.w[1] = (x.w[1] & 0x0001ffffffffffffull);
......@@ -382,17 +366,9 @@ _dpd_to_bid128 (_Decimal128 *pres, _Decimal128 *px) {
trailing.w[1] = x.w[1];
trailing.w[0] = x.w[0];
if ((comb & 0x1e000) == 0x1e000) {
if ((comb & 0x1f000) == 0x1f000) { /* G0..G4 = 11111 -> NaN */
if (comb & 0x01000) { /* G5 = 1 -> sNaN */
*pres = x;
} else { /* G5 = 0 -> qNaN */
*pres = x;
}
} else { /* G0..G4 = 11110 -> INF */
*pres = x;
}
return;
} else { /* Normal number */
}
if ((comb & 0x18000) == 0x18000) { /* G0..G1 = 11 -> d0 = 8 + G4 */
d0 = d2b6[8 + ((comb & 0x01000) >> 12)];
exp = (comb & 0x06000) >> 1; /* exp leading bits are G2..G3 */
......@@ -418,6 +394,5 @@ _dpd_to_bid128 (_Decimal128 *pres, _Decimal128 *px) {
exp += (comb & 0xfff);
res.w[0] = bcoeff.w[0];
res.w[1] = (exp << 49) | sign.w[1] | bcoeff.w[1];
}
*pres = res;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment