52{
54 struct uint128 sigA;
56 struct uint128 sigB, sigZ;
58 struct uint128 uiZ;
59 union ui128_f128 uZ;
60
61 expA = expF128UI64( uiA64 );
62 sigA.v64 = fracF128UI64( uiA64 );
63 sigA.v0 = uiA0;
64 expB = expF128UI64( uiB64 );
65 sigB.v64 = fracF128UI64( uiB64 );
66 sigB.v0 = uiB0;
69 expDiff = expA - expB;
70 if ( 0 < expDiff ) goto expABigger;
71 if ( expDiff < 0 ) goto expBBigger;
72 if ( expA == 0x7FFF ) {
73 if ( sigA.v64 | sigA.v0 | sigB.v64 | sigB.v0 ) goto propagateNaN;
77 goto uiZ;
78 }
79 expZ = expA;
80 if ( ! expZ ) expZ = 1;
81 if ( sigB.v64 < sigA.v64 ) goto aBigger;
82 if ( sigA.v64 < sigB.v64 ) goto bBigger;
83 if ( sigB.v0 < sigA.v0 ) goto aBigger;
84 if ( sigA.v0 < sigB.v0 ) goto bBigger;
85 uiZ.v64 =
86 packToF128UI64(
88 uiZ.v0 = 0;
89 goto uiZ;
90 expBBigger:
91 if ( expB == 0x7FFF ) {
92 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
93 uiZ.v64 = packToF128UI64( signZ ^ 1, 0x7FFF, 0 );
94 uiZ.v0 = 0;
95 goto uiZ;
96 }
97 if ( expA ) {
98 sigA.v64 |=
UINT64_C( 0x0010000000000000 );
99 } else {
100 ++expDiff;
101 if ( ! expDiff ) goto newlyAlignedBBigger;
102 }
104 newlyAlignedBBigger:
105 expZ = expB;
106 sigB.v64 |=
UINT64_C( 0x0010000000000000 );
107 bBigger:
108 signZ = ! signZ;
110 goto normRoundPack;
111 expABigger:
112 if ( expA == 0x7FFF ) {
113 if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
114 uiZ.v64 = uiA64;
115 uiZ.v0 = uiA0;
116 goto uiZ;
117 }
118 if ( expB ) {
119 sigB.v64 |=
UINT64_C( 0x0010000000000000 );
120 } else {
121 --expDiff;
122 if ( ! expDiff ) goto newlyAlignedABigger;
123 }
125 newlyAlignedABigger:
126 expZ = expA;
127 sigA.v64 |=
UINT64_C( 0x0010000000000000 );
128 aBigger:
130 normRoundPack:
132 propagateNaN:
134 uiZ:
135 uZ.ui = uiZ;
136 return uZ.f;
137
138}
struct uint128 softfloat_propagateNaNF128UI(uint_fast64_t uiA64, uint_fast64_t uiA0, uint_fast64_t uiB64, uint_fast64_t uiB0)
void softfloat_raiseFlags(uint_fast8_t flags)
#define defaultNaNF128UI64
#define defaultNaNF128UI0
THREAD_LOCAL uint_fast8_t softfloat_roundingMode
float128_t softfloat_normRoundPackToF128(bool sign, int_fast32_t exp, uint_fast64_t sig64, uint_fast64_t sig0)
struct uint128 softfloat_shiftRightJam128(uint64_t a64, uint64_t a0, uint_fast32_t dist)
struct uint128 softfloat_shortShiftLeft128(uint64_t a64, uint64_t a0, uint_fast8_t dist)
struct uint128 softfloat_sub128(uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0)