Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
s_subMagsF128.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include "platform.h"
#include "internals.h"
#include "specialize.h"
#include "softfloat.h"
Include dependency graph for s_subMagsF128.c:

Go to the source code of this file.

Functions

float128_t softfloat_subMagsF128 (uint_fast64_t uiA64, uint_fast64_t uiA0, uint_fast64_t uiB64, uint_fast64_t uiB0, bool signZ)
 

Function Documentation

◆ softfloat_subMagsF128()

float128_t softfloat_subMagsF128 ( uint_fast64_t uiA64,
uint_fast64_t uiA0,
uint_fast64_t uiB64,
uint_fast64_t uiB0,
bool signZ )

Definition at line 45 of file s_subMagsF128.c.

52{
53 int_fast32_t expA;
54 struct uint128 sigA;
55 int_fast32_t expB;
56 struct uint128 sigB, sigZ;
57 int_fast32_t expDiff, expZ;
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;
67 sigA = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 4 );
68 sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 4 );
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;
75 uiZ.v64 = defaultNaNF128UI64;
76 uiZ.v0 = defaultNaNF128UI0;
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 }
103 sigA = softfloat_shiftRightJam128( sigA.v64, sigA.v0, -expDiff );
104 newlyAlignedBBigger:
105 expZ = expB;
106 sigB.v64 |= UINT64_C( 0x0010000000000000 );
107 bBigger:
108 signZ = ! signZ;
109 sigZ = softfloat_sub128( sigB.v64, sigB.v0, sigA.v64, sigA.v0 );
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 }
124 sigB = softfloat_shiftRightJam128( sigB.v64, sigB.v0, expDiff );
125 newlyAlignedABigger:
126 expZ = expA;
127 sigA.v64 |= UINT64_C( 0x0010000000000000 );
128 aBigger:
129 sigZ = softfloat_sub128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 );
130 normRoundPack:
131 return softfloat_normRoundPackToF128( signZ, expZ - 5, sigZ.v64, sigZ.v0 );
132 propagateNaN:
133 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
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
Definition specialize.h:337
#define defaultNaNF128UI0
Definition specialize.h:339
THREAD_LOCAL uint_fast8_t softfloat_roundingMode
@ softfloat_flag_invalid
Definition softfloat.h:89
@ softfloat_round_min
Definition softfloat.h:74
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)
Definition s_sub128.c:44
#define UINT64_C(val)
Definition stdint.h:284
int32_t int_fast32_t
Definition stdint.h:152
Here is the call graph for this function:
Here is the caller graph for this function: