Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
softfloat.hpp File Reference
#include <softfloat_types.h>
Include dependency graph for softfloat.hpp:

Go to the source code of this file.

Macros

#define THREAD_LOCAL   __thread
 

Functions

float16_t ui32_to_f16 (uint32_t)
 
float32_t ui32_to_f32 (uint32_t)
 
float64_t ui32_to_f64 (uint32_t)
 
float128_t ui32_to_f128 (uint32_t)
 
void ui32_to_f128M (uint32_t, float128_t *)
 
float16_t ui64_to_f16 (uint64_t)
 
float32_t ui64_to_f32 (uint64_t)
 
float64_t ui64_to_f64 (uint64_t)
 
float128_t ui64_to_f128 (uint64_t)
 
void ui64_to_f128M (uint64_t, float128_t *)
 
float16_t i32_to_f16 (int32_t)
 
float32_t i32_to_f32 (int32_t)
 
float64_t i32_to_f64 (int32_t)
 
float128_t i32_to_f128 (int32_t)
 
void i32_to_f128M (int32_t, float128_t *)
 
float16_t i64_to_f16 (int64_t)
 
float32_t i64_to_f32 (int64_t)
 
float64_t i64_to_f64 (int64_t)
 
float128_t i64_to_f128 (int64_t)
 
void i64_to_f128M (int64_t, float128_t *)
 
uint_fast32_t f16_to_ui32 (float16_t, uint_fast8_t, bool)
 
uint_fast64_t f16_to_ui64 (float16_t, uint_fast8_t, bool)
 
int_fast32_t f16_to_i32 (float16_t, uint_fast8_t, bool)
 
int_fast64_t f16_to_i64 (float16_t, uint_fast8_t, bool)
 
uint_fast32_t f16_to_ui32_r_minMag (float16_t, bool)
 
uint_fast64_t f16_to_ui64_r_minMag (float16_t, bool)
 
int_fast32_t f16_to_i32_r_minMag (float16_t, bool)
 
int_fast64_t f16_to_i64_r_minMag (float16_t, bool)
 
float32_t f16_to_f32 (float16_t)
 
float64_t f16_to_f64 (float16_t)
 
float128_t f16_to_f128 (float16_t)
 
void f16_to_f128M (float16_t, float128_t *)
 
float16_t f16_roundToInt (float16_t, uint_fast8_t, bool)
 
float16_t f16_add (float16_t, float16_t)
 
float16_t f16_sub (float16_t, float16_t)
 
float16_t f16_mul (float16_t, float16_t)
 
float16_t f16_mulAdd (float16_t, float16_t, float16_t)
 
float16_t f16_div (float16_t, float16_t)
 
float16_t f16_rem (float16_t, float16_t)
 
float16_t f16_sqrt (float16_t)
 
bool f16_eq (float16_t, float16_t)
 
bool f16_le (float16_t, float16_t)
 
bool f16_lt (float16_t, float16_t)
 
bool f16_eq_signaling (float16_t, float16_t)
 
bool f16_le_quiet (float16_t, float16_t)
 
bool f16_lt_quiet (float16_t, float16_t)
 
bool f16_isSignalingNaN (float16_t)
 
uint_fast32_t f32_to_ui32 (float32_t, uint_fast8_t, bool)
 
uint_fast64_t f32_to_ui64 (float32_t, uint_fast8_t, bool)
 
int_fast32_t f32_to_i32 (float32_t, uint_fast8_t, bool)
 
int_fast64_t f32_to_i64 (float32_t, uint_fast8_t, bool)
 
uint_fast32_t f32_to_ui32_r_minMag (float32_t, bool)
 
uint_fast64_t f32_to_ui64_r_minMag (float32_t, bool)
 
int_fast32_t f32_to_i32_r_minMag (float32_t, bool)
 
int_fast64_t f32_to_i64_r_minMag (float32_t, bool)
 
float16_t f32_to_f16 (float32_t)
 
float64_t f32_to_f64 (float32_t)
 
float128_t f32_to_f128 (float32_t)
 
void f32_to_f128M (float32_t, float128_t *)
 
float32_t f32_roundToInt (float32_t, uint_fast8_t, bool)
 
float32_t f32_add (float32_t, float32_t)
 
float32_t f32_sub (float32_t, float32_t)
 
float32_t f32_mul (float32_t, float32_t)
 
float32_t f32_mulAdd (float32_t, float32_t, float32_t)
 
float32_t f32_div (float32_t, float32_t)
 
float32_t f32_rem (float32_t, float32_t)
 
float32_t f32_sqrt (float32_t)
 
bool f32_eq (float32_t, float32_t)
 
bool f32_le (float32_t, float32_t)
 
bool f32_lt (float32_t, float32_t)
 
bool f32_eq_signaling (float32_t, float32_t)
 
bool f32_le_quiet (float32_t, float32_t)
 
bool f32_lt_quiet (float32_t, float32_t)
 
bool f32_isSignalingNaN (float32_t)
 
uint_fast32_t f64_to_ui32 (float64_t, uint_fast8_t, bool)
 
uint_fast64_t f64_to_ui64 (float64_t, uint_fast8_t, bool)
 
int_fast32_t f64_to_i32 (float64_t, uint_fast8_t, bool)
 
int_fast64_t f64_to_i64 (float64_t, uint_fast8_t, bool)
 
uint_fast32_t f64_to_ui32_r_minMag (float64_t, bool)
 
uint_fast64_t f64_to_ui64_r_minMag (float64_t, bool)
 
int_fast32_t f64_to_i32_r_minMag (float64_t, bool)
 
int_fast64_t f64_to_i64_r_minMag (float64_t, bool)
 
float16_t f64_to_f16 (float64_t)
 
float32_t f64_to_f32 (float64_t)
 
float128_t f64_to_f128 (float64_t)
 
void f64_to_f128M (float64_t, float128_t *)
 
float64_t f64_roundToInt (float64_t, uint_fast8_t, bool)
 
float64_t f64_add (float64_t, float64_t)
 
float64_t f64_sub (float64_t, float64_t)
 
float64_t f64_mul (float64_t, float64_t)
 
float64_t f64_mulAdd (float64_t, float64_t, float64_t)
 
float64_t f64_div (float64_t, float64_t)
 
float64_t f64_rem (float64_t, float64_t)
 
float64_t f64_sqrt (float64_t)
 
bool f64_eq (float64_t, float64_t)
 
bool f64_le (float64_t, float64_t)
 
bool f64_lt (float64_t, float64_t)
 
bool f64_eq_signaling (float64_t, float64_t)
 
bool f64_le_quiet (float64_t, float64_t)
 
bool f64_lt_quiet (float64_t, float64_t)
 
bool f64_isSignalingNaN (float64_t)
 
uint_fast32_t f128_to_ui32 (float128_t, uint_fast8_t, bool)
 
uint_fast64_t f128_to_ui64 (float128_t, uint_fast8_t, bool)
 
int_fast32_t f128_to_i32 (float128_t, uint_fast8_t, bool)
 
int_fast64_t f128_to_i64 (float128_t, uint_fast8_t, bool)
 
uint_fast32_t f128_to_ui32_r_minMag (float128_t, bool)
 
uint_fast64_t f128_to_ui64_r_minMag (float128_t, bool)
 
int_fast32_t f128_to_i32_r_minMag (float128_t, bool)
 
int_fast64_t f128_to_i64_r_minMag (float128_t, bool)
 
float16_t f128_to_f16 (float128_t)
 
float32_t f128_to_f32 (float128_t)
 
float64_t f128_to_f64 (float128_t)
 
float128_t f128_roundToInt (float128_t, uint_fast8_t, bool)
 
float128_t f128_add (float128_t, float128_t)
 
float128_t f128_sub (float128_t, float128_t)
 
float128_t f128_mul (float128_t, float128_t)
 
float128_t f128_mulAdd (float128_t, float128_t, float128_t)
 
float128_t f128_div (float128_t, float128_t)
 
float128_t f128_rem (float128_t, float128_t)
 
float128_t f128_sqrt (float128_t)
 
bool f128_eq (float128_t, float128_t)
 
bool f128_le (float128_t, float128_t)
 
bool f128_lt (float128_t, float128_t)
 
bool f128_eq_signaling (float128_t, float128_t)
 
bool f128_le_quiet (float128_t, float128_t)
 
bool f128_lt_quiet (float128_t, float128_t)
 
bool f128_isSignalingNaN (float128_t)
 
void f128M_to_extF80M (const float128_t *, extFloat80_t *)
 
uint_fast32_t f128M_to_ui32 (const float128_t *, uint_fast8_t, bool)
 
uint_fast64_t f128M_to_ui64 (const float128_t *, uint_fast8_t, bool)
 
int_fast32_t f128M_to_i32 (const float128_t *, uint_fast8_t, bool)
 
int_fast64_t f128M_to_i64 (const float128_t *, uint_fast8_t, bool)
 
uint_fast32_t f128M_to_ui32_r_minMag (const float128_t *, bool)
 
uint_fast64_t f128M_to_ui64_r_minMag (const float128_t *, bool)
 
int_fast32_t f128M_to_i32_r_minMag (const float128_t *, bool)
 
int_fast64_t f128M_to_i64_r_minMag (const float128_t *, bool)
 
float16_t f128M_to_f16 (const float128_t *)
 
float32_t f128M_to_f32 (const float128_t *)
 
float64_t f128M_to_f64 (const float128_t *)
 
void f128M_roundToInt (const float128_t *, uint_fast8_t, bool, float128_t *)
 
void f128M_add (const float128_t *, const float128_t *, float128_t *)
 
void f128M_sub (const float128_t *, const float128_t *, float128_t *)
 
void f128M_mul (const float128_t *, const float128_t *, float128_t *)
 
void f128M_mulAdd (const float128_t *, const float128_t *, const float128_t *, float128_t *)
 
void f128M_div (const float128_t *, const float128_t *, float128_t *)
 
void f128M_rem (const float128_t *, const float128_t *, float128_t *)
 
void f128M_sqrt (const float128_t *, float128_t *)
 
bool f128M_eq (const float128_t *, const float128_t *)
 
bool f128M_le (const float128_t *, const float128_t *)
 
bool f128M_lt (const float128_t *, const float128_t *)
 
bool f128M_eq_signaling (const float128_t *, const float128_t *)
 
bool f128M_le_quiet (const float128_t *, const float128_t *)
 
bool f128M_lt_quiet (const float128_t *, const float128_t *)
 
bool f128M_isSignalingNaN (const float128_t *)
 
bool isNaNF128 (const float128_t *)
 
bool operator== (const float32_t &lhs, const float32_t &rhs)
 
bool operator!= (const float32_t &lhs, const float32_t &rhs)
 
bool operator< (const float32_t &lhs, const float32_t &rhs)
 
bool operator> (const float32_t &lhs, const float32_t &rhs)
 
bool operator<= (const float32_t &lhs, const float32_t &rhs)
 
bool operator>= (const float32_t &lhs, const float32_t &rhs)
 
bool operator== (const float64_t &lhs, const float64_t &rhs)
 
bool operator!= (const float64_t &lhs, const float64_t &rhs)
 
bool operator< (const float64_t &lhs, const float64_t &rhs)
 
bool operator> (const float64_t &lhs, const float64_t &rhs)
 
bool operator<= (const float64_t &lhs, const float64_t &rhs)
 
bool operator>= (const float64_t &lhs, const float64_t &rhs)
 
bool operator== (const float128_t &lhs, const float128_t &rhs)
 
bool operator!= (const float128_t &lhs, const float128_t &rhs)
 
bool operator< (const float128_t &lhs, const float128_t &rhs)
 
bool operator> (const float128_t &lhs, const float128_t &rhs)
 
bool operator<= (const float128_t &lhs, const float128_t &rhs)
 
bool operator>= (const float128_t &lhs, const float128_t &rhs)
 
bool f32_sign_bit (float32_t f)
 
bool f64_sign_bit (float64_t f)
 
bool f128_sign_bit (float128_t f)
 
bool f32_is_nan (const float32_t f)
 
bool f64_is_nan (const float64_t f)
 
bool f128_is_nan (const float128_t &f)
 
float32_t f32_negative_infinity ()
 
float32_t f32_positive_infinity ()
 
float64_t f64_negative_infinity ()
 
float64_t f64_positive_infinity ()
 
float128_t f128_negative_infinity ()
 
float128_t f128_positive_infinity ()
 
float32_t to_softfloat32 (float f)
 
float64_t to_softfloat64 (double d)
 
float from_softfloat32 (float32_t f)
 
double from_softfloat64 (float64_t d)
 

Macro Definition Documentation

◆ THREAD_LOCAL

#define THREAD_LOCAL   __thread

Definition at line 6 of file softfloat.hpp.

Function Documentation

◆ f128_add()

float128_t f128_add ( float128_t a,
float128_t b )

Definition at line 43 of file f128_add.c.

44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 bool signA;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
53 (*magsFuncPtr)(
55#endif
56
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 signA = signF128UI64( uiA64 );
61 uB.f = b;
62 uiB64 = uB.ui.v64;
63 uiB0 = uB.ui.v0;
64 signB = signF128UI64( uiB64 );
65#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
66 if ( signA == signB ) {
67 return softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
68 } else {
69 return softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70 }
71#else
72 magsFuncPtr =
74 return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
75#endif
76
77}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
float128_t softfloat_addMagsF128(uint_fast64_t uiA64, uint_fast64_t uiA0, uint_fast64_t uiB64, uint_fast64_t uiB0, bool signZ)
float128_t softfloat_subMagsF128(uint_fast64_t uiA64, uint_fast64_t uiA0, uint_fast64_t uiB64, uint_fast64_t uiB0, bool signZ)
uint64_t uint_fast64_t
Definition stdint.h:157
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_div()

float128_t f128_div ( float128_t a,
float128_t b )

Definition at line 44 of file f128_div.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA;
51 union ui128_f128 uB;
52 uint_fast64_t uiB64, uiB0;
53 bool signB;
54 int_fast32_t expB;
55 struct uint128 sigB;
56 bool signZ;
57 struct exp32_sig128 normExpSig;
58 int_fast32_t expZ;
59 struct uint128 rem;
60 uint_fast32_t recip32;
61 int ix;
62 uint_fast64_t q64;
64 struct uint128 term;
65 uint_fast32_t qs[3];
66 uint_fast64_t sigZExtra;
67 struct uint128 sigZ, uiZ;
68 union ui128_f128 uZ;
69
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uA.f = a;
73 uiA64 = uA.ui.v64;
74 uiA0 = uA.ui.v0;
75 signA = signF128UI64( uiA64 );
76 expA = expF128UI64( uiA64 );
77 sigA.v64 = fracF128UI64( uiA64 );
78 sigA.v0 = uiA0;
79 uB.f = b;
80 uiB64 = uB.ui.v64;
81 uiB0 = uB.ui.v0;
82 signB = signF128UI64( uiB64 );
83 expB = expF128UI64( uiB64 );
84 sigB.v64 = fracF128UI64( uiB64 );
85 sigB.v0 = uiB0;
86 signZ = signA ^ signB;
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( expA == 0x7FFF ) {
90 if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
91 if ( expB == 0x7FFF ) {
92 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
93 goto invalid;
94 }
95 goto infinity;
96 }
97 if ( expB == 0x7FFF ) {
98 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
99 goto zero;
100 }
101 /*------------------------------------------------------------------------
102 *------------------------------------------------------------------------*/
103 if ( ! expB ) {
104 if ( ! (sigB.v64 | sigB.v0) ) {
105 if ( ! (expA | sigA.v64 | sigA.v0) ) goto invalid;
107 goto infinity;
108 }
109 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
110 expB = normExpSig.exp;
111 sigB = normExpSig.sig;
112 }
113 if ( ! expA ) {
114 if ( ! (sigA.v64 | sigA.v0) ) goto zero;
115 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
116 expA = normExpSig.exp;
117 sigA = normExpSig.sig;
118 }
119 /*------------------------------------------------------------------------
120 *------------------------------------------------------------------------*/
121 expZ = expA - expB + 0x3FFE;
122 sigA.v64 |= UINT64_C( 0x0001000000000000 );
123 sigB.v64 |= UINT64_C( 0x0001000000000000 );
124 rem = sigA;
125 if ( softfloat_lt128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 ) ) {
126 --expZ;
127 rem = softfloat_add128( sigA.v64, sigA.v0, sigA.v64, sigA.v0 );
128 }
129 recip32 = softfloat_approxRecip32_1( sigB.v64>>17 );
130 ix = 3;
131 for (;;) {
132 q64 = (uint_fast64_t) (uint32_t) (rem.v64>>19) * recip32;
133 q = (q64 + 0x80000000)>>32;
134 --ix;
135 if ( ix < 0 ) break;
136 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
137 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
138 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
139 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
140 --q;
141 rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
142 }
143 qs[ix] = q;
144 }
145 /*------------------------------------------------------------------------
146 *------------------------------------------------------------------------*/
147 if ( ((q + 1) & 7) < 2 ) {
148 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
149 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
150 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
151 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
152 --q;
153 rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
154 } else if ( softfloat_le128( sigB.v64, sigB.v0, rem.v64, rem.v0 ) ) {
155 ++q;
156 rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
157 }
158 if ( rem.v64 | rem.v0 ) q |= 1;
159 }
160 /*------------------------------------------------------------------------
161 *------------------------------------------------------------------------*/
162 sigZExtra = (uint64_t) ((uint_fast64_t) q<<60);
163 term = softfloat_shortShiftLeft128( 0, qs[1], 54 );
164 sigZ =
166 (uint_fast64_t) qs[2]<<19, ((uint_fast64_t) qs[0]<<25) + (q>>4),
167 term.v64, term.v0
168 );
169 return
170 softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 propagateNaN:
174 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
175 goto uiZ;
176 /*------------------------------------------------------------------------
177 *------------------------------------------------------------------------*/
178 invalid:
180 uiZ.v64 = defaultNaNF128UI64;
181 uiZ.v0 = defaultNaNF128UI0;
182 goto uiZ;
183 /*------------------------------------------------------------------------
184 *------------------------------------------------------------------------*/
185 infinity:
186 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
187 goto uiZ0;
188 /*------------------------------------------------------------------------
189 *------------------------------------------------------------------------*/
190 zero:
191 uiZ.v64 = packToF128UI64( signZ, 0, 0 );
192 uiZ0:
193 uiZ.v0 = 0;
194 uiZ:
195 uZ.ui = uiZ;
196 return uZ.f;
197
198}
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
uint32_t softfloat_approxRecip32_1(uint32_t a)
@ softfloat_flag_invalid
Definition softfloat.h:89
@ softfloat_flag_infinite
Definition softfloat.h:88
struct uint128 softfloat_add128(uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0)
Definition s_add128.c:44
bool softfloat_le128(uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0)
Definition s_le128.c:43
bool softfloat_lt128(uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0)
Definition s_lt128.c:43
struct uint128 softfloat_mul128By32(uint64_t a64, uint64_t a0, uint32_t b)
struct exp32_sig128 softfloat_normSubnormalF128Sig(uint_fast64_t sig64, uint_fast64_t sig0)
float128_t softfloat_roundPackToF128(bool sign, int_fast32_t exp, uint_fast64_t sig64, uint_fast64_t sig0, uint_fast64_t sigExtra)
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
unsigned int uint32_t
Definition stdint.h:126
#define UINT64_C(val)
Definition stdint.h:284
uint32_t uint_fast32_t
Definition stdint.h:156
int32_t int_fast32_t
Definition stdint.h:152
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_eq()

bool f128_eq ( float128_t a,
float128_t b )

Definition at line 44 of file f128_eq.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58 if (
59 softfloat_isSigNaNF128UI( uiA64, uiA0 )
60 || softfloat_isSigNaNF128UI( uiB64, uiB0 )
61 ) {
63 }
64 return false;
65 }
66 return
67 (uiA0 == uiB0)
68 && ( (uiA64 == uiB64)
69 || (! uiA0 && ! ((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
70 );
71
72}
Here is the call graph for this function:

◆ f128_eq_signaling()

bool f128_eq_signaling ( float128_t a,
float128_t b )

Definition at line 43 of file f128_eq_signaling.c.

44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 union ui128_f128 uB;
48 uint_fast64_t uiB64, uiB0;
49
50 uA.f = a;
51 uiA64 = uA.ui.v64;
52 uiA0 = uA.ui.v0;
53 uB.f = b;
54 uiB64 = uB.ui.v64;
55 uiB0 = uB.ui.v0;
56 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58 return false;
59 }
60 return
61 (uiA0 == uiB0)
62 && ( (uiA64 == uiB64)
63 || (! uiA0 && ! ((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
64 );
65
66}
Here is the call graph for this function:

◆ f128_is_nan()

bool f128_is_nan ( const float128_t & f)
inline

Definition at line 272 of file softfloat.hpp.

272 {
273 return (((~(f.v[1]) & uint64_t( 0x7FFF000000000000 )) == 0) && (f.v[0] || ((f.v[1]) & uint64_t( 0x0000FFFFFFFFFFFF ))));
274}

◆ f128_isSignalingNaN()

bool f128_isSignalingNaN ( float128_t a)

Definition at line 43 of file f128_isSignalingNaN.c.

44{
45 union ui128_f128 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF128UI( uA.ui.v64, uA.ui.v0 );
49
50}

◆ f128_le()

bool f128_le ( float128_t a,
float128_t b )

Definition at line 43 of file f128_le.c.

44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 union ui128_f128 uB;
48 uint_fast64_t uiB64, uiB0;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
59 return false;
60 }
61 signA = signF128UI64( uiA64 );
62 signB = signF128UI64( uiB64 );
63 return
64 (signA != signB)
65 ? signA
66 || ! (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
67 | uiA0 | uiB0)
68 : ((uiA64 == uiB64) && (uiA0 == uiB0))
69 || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
70
71}
Here is the call graph for this function:

◆ f128_le_quiet()

bool f128_le_quiet ( float128_t a,
float128_t b )

Definition at line 44 of file f128_le_quiet.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA64 = uA.ui.v64;
54 uiA0 = uA.ui.v0;
55 uB.f = b;
56 uiB64 = uB.ui.v64;
57 uiB0 = uB.ui.v0;
58 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
59 if (
60 softfloat_isSigNaNF128UI( uiA64, uiA0 )
61 || softfloat_isSigNaNF128UI( uiB64, uiB0 )
62 ) {
64 }
65 return false;
66 }
67 signA = signF128UI64( uiA64 );
68 signB = signF128UI64( uiB64 );
69 return
70 (signA != signB)
71 ? signA
72 || ! (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73 | uiA0 | uiB0)
74 : ((uiA64 == uiB64) && (uiA0 == uiB0))
75 || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
77}
Here is the call graph for this function:

◆ f128_lt()

bool f128_lt ( float128_t a,
float128_t b )

Definition at line 43 of file f128_lt.c.

44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 union ui128_f128 uB;
48 uint_fast64_t uiB64, uiB0;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
59 return false;
60 }
61 signA = signF128UI64( uiA64 );
62 signB = signF128UI64( uiB64 );
63 return
64 (signA != signB)
65 ? signA
66 && (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
67 | uiA0 | uiB0)
68 : ((uiA64 != uiB64) || (uiA0 != uiB0))
69 && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
70
71}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_lt_quiet()

bool f128_lt_quiet ( float128_t a,
float128_t b )

Definition at line 44 of file f128_lt_quiet.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA64 = uA.ui.v64;
54 uiA0 = uA.ui.v0;
55 uB.f = b;
56 uiB64 = uB.ui.v64;
57 uiB0 = uB.ui.v0;
58 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
59 if (
60 softfloat_isSigNaNF128UI( uiA64, uiA0 )
61 || softfloat_isSigNaNF128UI( uiB64, uiB0 )
62 ) {
64 }
65 return false;
66 }
67 signA = signF128UI64( uiA64 );
68 signB = signF128UI64( uiB64 );
69 return
70 (signA != signB)
71 ? signA
72 && (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73 | uiA0 | uiB0)
74 : ((uiA64 != uiB64) || (uiA0 != uiB0))
75 && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
77}
Here is the call graph for this function:

◆ f128_mul()

float128_t f128_mul ( float128_t a,
float128_t b )

Definition at line 44 of file f128_mul.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA;
51 union ui128_f128 uB;
52 uint_fast64_t uiB64, uiB0;
53 bool signB;
54 int_fast32_t expB;
55 struct uint128 sigB;
56 bool signZ;
57 uint_fast64_t magBits;
58 struct exp32_sig128 normExpSig;
59 int_fast32_t expZ;
60 uint64_t sig256Z[4];
61 uint_fast64_t sigZExtra;
62 struct uint128 sigZ;
63 struct uint128_extra sig128Extra;
64 struct uint128 uiZ;
65 union ui128_f128 uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uA.f = a;
70 uiA64 = uA.ui.v64;
71 uiA0 = uA.ui.v0;
72 signA = signF128UI64( uiA64 );
73 expA = expF128UI64( uiA64 );
74 sigA.v64 = fracF128UI64( uiA64 );
75 sigA.v0 = uiA0;
76 uB.f = b;
77 uiB64 = uB.ui.v64;
78 uiB0 = uB.ui.v0;
79 signB = signF128UI64( uiB64 );
80 expB = expF128UI64( uiB64 );
81 sigB.v64 = fracF128UI64( uiB64 );
82 sigB.v0 = uiB0;
83 signZ = signA ^ signB;
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 if ( expA == 0x7FFF ) {
87 if (
88 (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
89 ) {
90 goto propagateNaN;
91 }
92 magBits = expB | sigB.v64 | sigB.v0;
93 goto infArg;
94 }
95 if ( expB == 0x7FFF ) {
96 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
97 magBits = expA | sigA.v64 | sigA.v0;
98 goto infArg;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 if ( ! expA ) {
103 if ( ! (sigA.v64 | sigA.v0) ) goto zero;
104 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
105 expA = normExpSig.exp;
106 sigA = normExpSig.sig;
107 }
108 if ( ! expB ) {
109 if ( ! (sigB.v64 | sigB.v0) ) goto zero;
110 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
111 expB = normExpSig.exp;
112 sigB = normExpSig.sig;
113 }
114 /*------------------------------------------------------------------------
115 *------------------------------------------------------------------------*/
116 expZ = expA + expB - 0x4000;
117 sigA.v64 |= UINT64_C( 0x0001000000000000 );
118 sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 16 );
119 softfloat_mul128To256M( sigA.v64, sigA.v0, sigB.v64, sigB.v0, sig256Z );
120 sigZExtra = sig256Z[indexWord( 4, 1 )] | (sig256Z[indexWord( 4, 0 )] != 0);
121 sigZ =
123 sig256Z[indexWord( 4, 3 )], sig256Z[indexWord( 4, 2 )],
124 sigA.v64, sigA.v0
125 );
126 if ( UINT64_C( 0x0002000000000000 ) <= sigZ.v64 ) {
127 ++expZ;
128 sig128Extra =
130 sigZ.v64, sigZ.v0, sigZExtra, 1 );
131 sigZ = sig128Extra.v;
132 sigZExtra = sig128Extra.extra;
133 }
134 return
135 softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
136 /*------------------------------------------------------------------------
137 *------------------------------------------------------------------------*/
138 propagateNaN:
139 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
140 goto uiZ;
141 /*------------------------------------------------------------------------
142 *------------------------------------------------------------------------*/
143 infArg:
144 if ( ! magBits ) {
146 uiZ.v64 = defaultNaNF128UI64;
147 uiZ.v0 = defaultNaNF128UI0;
148 goto uiZ;
149 }
150 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
151 goto uiZ0;
152 /*------------------------------------------------------------------------
153 *------------------------------------------------------------------------*/
154 zero:
155 uiZ.v64 = packToF128UI64( signZ, 0, 0 );
156 uiZ0:
157 uiZ.v0 = 0;
158 uiZ:
159 uZ.ui = uiZ;
160 return uZ.f;
161
162}
#define indexWord(total, n)
#define softfloat_mul128To256M
struct uint128_extra softfloat_shortShiftRightJam128Extra(uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_mulAdd()

float128_t f128_mulAdd ( float128_t a,
float128_t b,
float128_t c )

Definition at line 42 of file f128_mulAdd.c.

43{
44 union ui128_f128 uA;
45 uint_fast64_t uiA64, uiA0;
46 union ui128_f128 uB;
47 uint_fast64_t uiB64, uiB0;
48 union ui128_f128 uC;
49 uint_fast64_t uiC64, uiC0;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 uC.f = c;
58 uiC64 = uC.ui.v64;
59 uiC0 = uC.ui.v0;
60 return softfloat_mulAddF128( uiA64, uiA0, uiB64, uiB0, uiC64, uiC0, 0 );
61
62}
float128_t softfloat_mulAddF128(uint_fast64_t uiA64, uint_fast64_t uiA0, uint_fast64_t uiB64, uint_fast64_t uiB0, uint_fast64_t uiC64, uint_fast64_t uiC0, uint_fast8_t op)
Here is the call graph for this function:

◆ f128_negative_infinity()

float128_t f128_negative_infinity ( )
inline

Definition at line 288 of file softfloat.hpp.

288 {
289 return {{0x0ull, 0xffff000000000000ull}};
290}

◆ f128_positive_infinity()

float128_t f128_positive_infinity ( )
inline

Definition at line 291 of file softfloat.hpp.

291 {
292 return {{0x0ull, 0x7fff000000000000ull}};
293}

◆ f128_rem()

float128_t f128_rem ( float128_t a,
float128_t b )

Definition at line 44 of file f128_rem.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA;
51 union ui128_f128 uB;
52 uint_fast64_t uiB64, uiB0;
53 int_fast32_t expB;
54 struct uint128 sigB;
55 struct exp32_sig128 normExpSig;
56 struct uint128 rem;
57 int_fast32_t expDiff;
58 uint_fast32_t q, recip32;
59 uint_fast64_t q64;
60 struct uint128 term, altRem, meanRem;
61 bool signRem;
62 struct uint128 uiZ;
63 union ui128_f128 uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 uA.f = a;
68 uiA64 = uA.ui.v64;
69 uiA0 = uA.ui.v0;
70 signA = signF128UI64( uiA64 );
71 expA = expF128UI64( uiA64 );
72 sigA.v64 = fracF128UI64( uiA64 );
73 sigA.v0 = uiA0;
74 uB.f = b;
75 uiB64 = uB.ui.v64;
76 uiB0 = uB.ui.v0;
77 expB = expF128UI64( uiB64 );
78 sigB.v64 = fracF128UI64( uiB64 );
79 sigB.v0 = uiB0;
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 if ( expA == 0x7FFF ) {
83 if (
84 (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
85 ) {
86 goto propagateNaN;
87 }
88 goto invalid;
89 }
90 if ( expB == 0x7FFF ) {
91 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
92 return a;
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 if ( ! expB ) {
97 if ( ! (sigB.v64 | sigB.v0) ) goto invalid;
98 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
99 expB = normExpSig.exp;
100 sigB = normExpSig.sig;
101 }
102 if ( ! expA ) {
103 if ( ! (sigA.v64 | sigA.v0) ) return a;
104 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
105 expA = normExpSig.exp;
106 sigA = normExpSig.sig;
107 }
108 /*------------------------------------------------------------------------
109 *------------------------------------------------------------------------*/
110 sigA.v64 |= UINT64_C( 0x0001000000000000 );
111 sigB.v64 |= UINT64_C( 0x0001000000000000 );
112 rem = sigA;
113 expDiff = expA - expB;
114 if ( expDiff < 1 ) {
115 if ( expDiff < -1 ) return a;
116 if ( expDiff ) {
117 --expB;
118 sigB = softfloat_add128( sigB.v64, sigB.v0, sigB.v64, sigB.v0 );
119 q = 0;
120 } else {
121 q = softfloat_le128( sigB.v64, sigB.v0, rem.v64, rem.v0 );
122 if ( q ) {
123 rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
124 }
125 }
126 } else {
127 recip32 = softfloat_approxRecip32_1( sigB.v64>>17 );
128 expDiff -= 30;
129 for (;;) {
130 q64 = (uint_fast64_t) (uint32_t) (rem.v64>>19) * recip32;
131 if ( expDiff < 0 ) break;
132 q = (q64 + 0x80000000)>>32;
133 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
134 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
135 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
136 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
137 rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
138 }
139 expDiff -= 29;
140 }
141 /*--------------------------------------------------------------------
142 | (`expDiff' cannot be less than -29 here.)
143 *--------------------------------------------------------------------*/
144 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
145 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, expDiff + 30 );
146 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
147 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
148 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
149 altRem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
150 goto selectRem;
151 }
152 }
153 /*------------------------------------------------------------------------
154 *------------------------------------------------------------------------*/
155 do {
156 altRem = rem;
157 ++q;
158 rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
159 } while ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) );
160 selectRem:
161 meanRem = softfloat_add128( rem.v64, rem.v0, altRem.v64, altRem.v0 );
162 if (
163 (meanRem.v64 & UINT64_C( 0x8000000000000000 ))
164 || (! (meanRem.v64 | meanRem.v0) && (q & 1))
165 ) {
166 rem = altRem;
167 }
168 signRem = signA;
169 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
170 signRem = ! signRem;
171 rem = softfloat_sub128( 0, 0, rem.v64, rem.v0 );
172 }
173 return softfloat_normRoundPackToF128( signRem, expB - 1, rem.v64, rem.v0 );
174 /*------------------------------------------------------------------------
175 *------------------------------------------------------------------------*/
176 propagateNaN:
177 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
178 goto uiZ;
179 /*------------------------------------------------------------------------
180 *------------------------------------------------------------------------*/
181 invalid:
183 uiZ.v64 = defaultNaNF128UI64;
184 uiZ.v0 = defaultNaNF128UI0;
185 uiZ:
186 uZ.ui = uiZ;
187 return uZ.f;
188
189}
float128_t softfloat_normRoundPackToF128(bool sign, int_fast32_t exp, uint_fast64_t sig64, uint_fast64_t sig0)
Here is the call graph for this function:

◆ f128_roundToInt()

float128_t f128_roundToInt ( float128_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 45 of file f128_roundToInt.c.

46{
47 union ui128_f128 uA;
48 uint_fast64_t uiA64, uiA0;
49 int_fast32_t exp;
50 struct uint128 uiZ;
51 uint_fast64_t lastBitMask0, roundBitsMask;
52 bool roundNearEven;
53 uint_fast64_t lastBitMask64;
54 union ui128_f128 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.ui.v64;
60 uiA0 = uA.ui.v0;
61 exp = expF128UI64( uiA64 );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( 0x402F <= exp ) {
65 /*--------------------------------------------------------------------
66 *--------------------------------------------------------------------*/
67 if ( 0x406F <= exp ) {
68 if ( (exp == 0x7FFF) && (fracF128UI64( uiA64 ) | uiA0) ) {
69 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, 0, 0 );
70 goto uiZ;
71 }
72 return a;
73 }
74 /*--------------------------------------------------------------------
75 *--------------------------------------------------------------------*/
76 lastBitMask0 = (uint_fast64_t) 2<<(0x406E - exp);
77 roundBitsMask = lastBitMask0 - 1;
78 uiZ.v64 = uiA64;
79 uiZ.v0 = uiA0;
80 roundNearEven = (roundingMode == softfloat_round_near_even);
81 if ( roundNearEven || (roundingMode == softfloat_round_near_maxMag) ) {
82 if ( exp == 0x402F ) {
83 if ( UINT64_C( 0x8000000000000000 ) <= uiZ.v0 ) {
84 ++uiZ.v64;
85 if (
86 roundNearEven
87 && (uiZ.v0 == UINT64_C( 0x8000000000000000 ))
88 ) {
89 uiZ.v64 &= ~1;
90 }
91 }
92 } else {
93 uiZ = softfloat_add128( uiZ.v64, uiZ.v0, 0, lastBitMask0>>1 );
94 if ( roundNearEven && !(uiZ.v0 & roundBitsMask) ) {
95 uiZ.v0 &= ~lastBitMask0;
96 }
97 }
98 } else if (
99 roundingMode
100 == (signF128UI64( uiZ.v64 ) ? softfloat_round_min
102 ) {
103 uiZ = softfloat_add128( uiZ.v64, uiZ.v0, 0, roundBitsMask );
104 }
105 uiZ.v0 &= ~roundBitsMask;
106 lastBitMask64 = !lastBitMask0;
107 } else {
108 /*--------------------------------------------------------------------
109 *--------------------------------------------------------------------*/
110 if ( exp < 0x3FFF ) {
111 if ( !((uiA64 & UINT64_C( 0x7FFFFFFFFFFFFFFF )) | uiA0) ) return a;
113 uiZ.v64 = uiA64 & packToF128UI64( 1, 0, 0 );
114 uiZ.v0 = 0;
115 switch ( roundingMode ) {
117 if ( !(fracF128UI64( uiA64 ) | uiA0) ) break;
119 if ( exp == 0x3FFE ) uiZ.v64 |= packToF128UI64( 0, 0x3FFF, 0 );
120 break;
122 if ( uiZ.v64 ) uiZ.v64 = packToF128UI64( 1, 0x3FFF, 0 );
123 break;
125 if ( !uiZ.v64 ) uiZ.v64 = packToF128UI64( 0, 0x3FFF, 0 );
126 break;
127#ifdef SOFTFLOAT_ROUND_ODD
129 uiZ.v64 |= packToF128UI64( 0, 0x3FFF, 0 );
130 break;
131#endif
132 }
133 goto uiZ;
134 }
135 /*--------------------------------------------------------------------
136 *--------------------------------------------------------------------*/
137 uiZ.v64 = uiA64;
138 uiZ.v0 = 0;
139 lastBitMask64 = (uint_fast64_t) 1<<(0x402F - exp);
140 roundBitsMask = lastBitMask64 - 1;
141 if ( roundingMode == softfloat_round_near_maxMag ) {
142 uiZ.v64 += lastBitMask64>>1;
143 } else if ( roundingMode == softfloat_round_near_even ) {
144 uiZ.v64 += lastBitMask64>>1;
145 if ( !((uiZ.v64 & roundBitsMask) | uiA0) ) {
146 uiZ.v64 &= ~lastBitMask64;
147 }
148 } else if (
149 roundingMode
150 == (signF128UI64( uiZ.v64 ) ? softfloat_round_min
152 ) {
153 uiZ.v64 = (uiZ.v64 | (uiA0 != 0)) + roundBitsMask;
154 }
155 uiZ.v64 &= ~roundBitsMask;
156 lastBitMask0 = 0;
157 }
158 if ( (uiZ.v64 != uiA64) || (uiZ.v0 != uiA0) ) {
159#ifdef SOFTFLOAT_ROUND_ODD
160 if ( roundingMode == softfloat_round_odd ) {
161 uiZ.v64 |= lastBitMask64;
162 uiZ.v0 |= lastBitMask0;
163 }
164#endif
166 }
167 uiZ:
168 uZ.ui = uiZ;
169 return uZ.f;
170
171}
@ softfloat_flag_inexact
Definition softfloat.h:85
THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags
@ softfloat_round_odd
Definition softfloat.h:77
@ softfloat_round_max
Definition softfloat.h:75
@ softfloat_round_min
Definition softfloat.h:74
@ softfloat_round_near_even
Definition softfloat.h:72
@ softfloat_round_near_maxMag
Definition softfloat.h:76
Here is the call graph for this function:

◆ f128_sign_bit()

bool f128_sign_bit ( float128_t f)
inline

Definition at line 264 of file softfloat.hpp.

264{ return f.v[1] >> 63; }

◆ f128_sqrt()

float128_t f128_sqrt ( float128_t a)

Definition at line 44 of file f128_sqrt.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA, uiZ;
51 struct exp32_sig128 normExpSig;
52 int_fast32_t expZ;
53 uint_fast32_t sig32A, recipSqrt32, sig32Z;
54 struct uint128 rem;
55 uint32_t qs[3];
57 uint_fast64_t x64, sig64Z;
58 struct uint128 y, term;
59 uint_fast64_t sigZExtra;
60 struct uint128 sigZ;
61 union ui128_f128 uZ;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 uA.f = a;
66 uiA64 = uA.ui.v64;
67 uiA0 = uA.ui.v0;
68 signA = signF128UI64( uiA64 );
69 expA = expF128UI64( uiA64 );
70 sigA.v64 = fracF128UI64( uiA64 );
71 sigA.v0 = uiA0;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( expA == 0x7FFF ) {
75 if ( sigA.v64 | sigA.v0 ) {
76 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, 0, 0 );
77 goto uiZ;
78 }
79 if ( ! signA ) return a;
80 goto invalid;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( signA ) {
85 if ( ! (expA | sigA.v64 | sigA.v0) ) return a;
86 goto invalid;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! expA ) {
91 if ( ! (sigA.v64 | sigA.v0) ) return a;
92 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
93 expA = normExpSig.exp;
94 sigA = normExpSig.sig;
95 }
96 /*------------------------------------------------------------------------
97 | (`sig32Z' is guaranteed to be a lower bound on the square root of
98 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
99 | `sigA'.)
100 *------------------------------------------------------------------------*/
101 expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
102 expA &= 1;
103 sigA.v64 |= UINT64_C( 0x0001000000000000 );
104 sig32A = sigA.v64>>17;
105 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
106 sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
107 if ( expA ) {
108 sig32Z >>= 1;
109 rem = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 12 );
110 } else {
111 rem = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 13 );
112 }
113 qs[2] = sig32Z;
114 rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
115 /*------------------------------------------------------------------------
116 *------------------------------------------------------------------------*/
117 q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
118 x64 = (uint_fast64_t) sig32Z<<32;
119 sig64Z = x64 + ((uint_fast64_t) q<<3);
120 y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
121 /*------------------------------------------------------------------------
122 | (Repeating this loop is a rare occurrence.)
123 *------------------------------------------------------------------------*/
124 for (;;) {
125 term = softfloat_mul64ByShifted32To128( x64 + sig64Z, q );
126 rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
127 if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
128 --q;
129 sig64Z -= 1<<3;
130 }
131 qs[1] = q;
132 /*------------------------------------------------------------------------
133 *------------------------------------------------------------------------*/
134 q = ((rem.v64>>2) * recipSqrt32)>>32;
135 y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
136 sig64Z <<= 1;
137 /*------------------------------------------------------------------------
138 | (Repeating this loop is a rare occurrence.)
139 *------------------------------------------------------------------------*/
140 for (;;) {
141 term = softfloat_shortShiftLeft128( 0, sig64Z, 32 );
142 term = softfloat_add128( term.v64, term.v0, 0, (uint_fast64_t) q<<6 );
143 term = softfloat_mul128By32( term.v64, term.v0, q );
144 rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
145 if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
146 --q;
147 }
148 qs[0] = q;
149 /*------------------------------------------------------------------------
150 *------------------------------------------------------------------------*/
151 q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
152 sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
153 term = softfloat_shortShiftLeft128( 0, qs[1], 53 );
154 sigZ =
156 (uint_fast64_t) qs[2]<<18, ((uint_fast64_t) qs[0]<<24) + (q>>5),
157 term.v64, term.v0
158 );
159 /*------------------------------------------------------------------------
160 *------------------------------------------------------------------------*/
161 if ( (q & 0xF) <= 2 ) {
162 q &= ~3;
163 sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
164 y = softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, 6 );
165 y.v0 |= sigZExtra>>58;
166 term = softfloat_sub128( y.v64, y.v0, 0, q );
167 y = softfloat_mul64ByShifted32To128( term.v0, q );
168 term = softfloat_mul64ByShifted32To128( term.v64, q );
169 term = softfloat_add128( term.v64, term.v0, 0, y.v64 );
170 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 20 );
171 term = softfloat_sub128( term.v64, term.v0, rem.v64, rem.v0 );
172 /*--------------------------------------------------------------------
173 | The concatenation of `term' and `y.v0' is now the negative remainder
174 | (3 words altogether).
175 *--------------------------------------------------------------------*/
176 if ( term.v64 & UINT64_C( 0x8000000000000000 ) ) {
177 sigZExtra |= 1;
178 } else {
179 if ( term.v64 | term.v0 | y.v0 ) {
180 if ( sigZExtra ) {
181 --sigZExtra;
182 } else {
183 sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, 0, 1 );
184 sigZExtra = ~0;
185 }
186 }
187 }
188 }
189 return softfloat_roundPackToF128( 0, expZ, sigZ.v64, sigZ.v0, sigZExtra );
190 /*------------------------------------------------------------------------
191 *------------------------------------------------------------------------*/
192 invalid:
194 uiZ.v64 = defaultNaNF128UI64;
195 uiZ.v0 = defaultNaNF128UI0;
196 uiZ:
197 uZ.ui = uiZ;
198 return uZ.f;
199
200}
uint64_t y
Definition sha3.cpp:34
uint32_t softfloat_approxRecipSqrt32_1(unsigned int oddExpA, uint32_t a)
struct uint128 softfloat_mul64ByShifted32To128(uint64_t a, uint32_t b)
Here is the call graph for this function:

◆ f128_sub()

float128_t f128_sub ( float128_t a,
float128_t b )

Definition at line 43 of file f128_sub.c.

44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 bool signA;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
53 (*magsFuncPtr)(
55#endif
56
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 signA = signF128UI64( uiA64 );
61 uB.f = b;
62 uiB64 = uB.ui.v64;
63 uiB0 = uB.ui.v0;
64 signB = signF128UI64( uiB64 );
65#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
66 if ( signA == signB ) {
67 return softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
68 } else {
69 return softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70 }
71#else
72 magsFuncPtr =
74 return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
75#endif
76
77}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_to_f16()

float16_t f128_to_f16 ( float128_t a)

Definition at line 44 of file f128_to_f16.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64;
51 struct commonNaN commonNaN;
52 uint_fast16_t uiZ, frac16;
53 union ui16_f16 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x7FFF ) {
66 if ( frac64 ) {
69 } else {
70 uiZ = packToF16UI( sign, 0x1F, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 frac16 = softfloat_shortShiftRightJam64( frac64, 34 );
77 if ( ! (exp | frac16) ) {
78 uiZ = packToF16UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 exp -= 0x3FF1;
84 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
85 if ( exp < -0x40 ) exp = -0x40;
86 }
87 return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 uiZ:
91 uZ.ui = uiZ;
92 return uZ.f;
93
94}
void softfloat_f128UIToCommonNaN(uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr)
#define softfloat_commonNaNToF16UI(aPtr)
Definition specialize.h:102
float16_t softfloat_roundPackToF16(bool, int_fast16_t, uint_fast16_t)
#define packToF16UI(sign, exp, sig)
Definition internals.h:86
uint64_t softfloat_shortShiftRightJam64(uint64_t a, uint_fast8_t dist)
uint16_t uint_fast16_t
Definition stdint.h:155
int16_t int_fast16_t
Definition stdint.h:151
float16_t f
Definition internals.h:45
Here is the call graph for this function:

◆ f128_to_f32()

float32_t f128_to_f32 ( float128_t a)

Definition at line 44 of file f128_to_f32.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64;
51 struct commonNaN commonNaN;
52 uint_fast32_t uiZ, frac32;
53 union ui32_f32 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x7FFF ) {
66 if ( frac64 ) {
69 } else {
70 uiZ = packToF32UI( sign, 0xFF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
77 if ( ! (exp | frac32) ) {
78 uiZ = packToF32UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 exp -= 0x3F81;
84 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
85 if ( exp < -0x1000 ) exp = -0x1000;
86 }
87 return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 uiZ:
91 uZ.ui = uiZ;
92 return uZ.f;
93
94}
#define softfloat_commonNaNToF32UI(aPtr)
Definition specialize.h:137
float32_t softfloat_roundPackToF32(bool, int_fast16_t, uint_fast32_t)
#define packToF32UI(sign, exp, sig)
Definition internals.h:107
float32_t f
Definition internals.h:46
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_to_f64()

float64_t f128_to_f64 ( float128_t a)

Definition at line 44 of file f128_to_f64.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64, frac0;
51 struct commonNaN commonNaN;
52 uint_fast64_t uiZ;
53 struct uint128 frac128;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.ui.v64;
60 uiA0 = uA.ui.v0;
61 sign = signF128UI64( uiA64 );
62 exp = expF128UI64( uiA64 );
63 frac64 = fracF128UI64( uiA64 );
64 frac0 = uiA0;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp == 0x7FFF ) {
68 if ( frac64 | frac0 ) {
71 } else {
72 uiZ = packToF64UI( sign, 0x7FF, 0 );
73 }
74 goto uiZ;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 frac128 = softfloat_shortShiftLeft128( frac64, frac0, 14 );
79 frac64 = frac128.v64 | (frac128.v0 != 0);
80 if ( ! (exp | frac64) ) {
81 uiZ = packToF64UI( sign, 0, 0 );
82 goto uiZ;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 exp -= 0x3C01;
87 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
88 if ( exp < -0x1000 ) exp = -0x1000;
89 }
90 return
92 sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 uiZ:
96 uZ.ui = uiZ;
97 return uZ.f;
98
99}
#define softfloat_commonNaNToF64UI(aPtr)
Definition specialize.h:172
float64_t softfloat_roundPackToF64(bool, int_fast16_t, uint_fast64_t)
#define packToF64UI(sign, exp, sig)
Definition internals.h:128
float64_t f
Definition internals.h:47
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_to_i32()

int_fast32_t f128_to_i32 ( float128_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f128_to_i32.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA64 = uA.ui.v64;
57 uiA0 = uA.ui.v0;
58 sign = signF128UI64( uiA64 );
59 exp = expF128UI64( uiA64 );
60 sig64 = fracF128UI64( uiA64 );
61 sig0 = uiA0;
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
65 if ( (exp == 0x7FFF) && (sig64 | sig0) ) {
66#if (i32_fromNaN == i32_fromPosOverflow)
67 sign = 0;
68#elif (i32_fromNaN == i32_fromNegOverflow)
69 sign = 1;
70#else
72 return i32_fromNaN;
73#endif
74 }
75#endif
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
79 sig64 |= (sig0 != 0);
80 shiftDist = 0x4023 - exp;
81 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
82 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
83
84}
#define i32_fromNaN
Definition specialize.h:59
int_fast32_t softfloat_roundToI32(bool, uint_fast64_t, uint_fast8_t, bool)
uint64_t softfloat_shiftRightJam64(uint64_t a, uint_fast32_t dist)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_to_i32_r_minMag()

int_fast32_t f128_to_i32_r_minMag ( float128_t a,
bool exact )

Definition at line 44 of file f128_to_i32_r_minMag.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 int_fast32_t exp;
49 uint_fast64_t sig64;
50 int_fast32_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.ui.v64;
58 uiA0 = uA.ui.v0;
59 exp = expF128UI64( uiA64 );
60 sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0x402F - exp;
64 if ( 49 <= shiftDist ) {
65 if ( exact && (exp | sig64) ) {
67 }
68 return 0;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 sign = signF128UI64( uiA64 );
73 if ( shiftDist < 18 ) {
74 if (
75 sign && (shiftDist == 17)
76 && (sig64 < UINT64_C( 0x0000000000020000 ))
77 ) {
78 if ( exact && sig64 ) {
80 }
81 return -0x7FFFFFFF - 1;
82 }
84 return
85 (exp == 0x7FFF) && sig64 ? i32_fromNaN
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 sig64 |= UINT64_C( 0x0001000000000000 );
91 absZ = sig64>>shiftDist;
92 if (
93 exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig64)
94 ) {
96 }
97 return sign ? -absZ : absZ;
98
99}
#define i32_fromNegOverflow
Definition specialize.h:58
#define i32_fromPosOverflow
Definition specialize.h:57
Here is the call graph for this function:

◆ f128_to_i64()

int_fast64_t f128_to_i64 ( float128_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f128_to_i64.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52 struct uint128 sig128;
53 struct uint64_extra sigExtra;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 sig64 = fracF128UI64( uiA64 );
63 sig0 = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 shiftDist = 0x402F - exp;
67 if ( shiftDist <= 0 ) {
68 /*--------------------------------------------------------------------
69 *--------------------------------------------------------------------*/
70 if ( shiftDist < -15 ) {
72 return
73 (exp == 0x7FFF) && (sig64 | sig0) ? i64_fromNaN
75 }
76 /*--------------------------------------------------------------------
77 *--------------------------------------------------------------------*/
78 sig64 |= UINT64_C( 0x0001000000000000 );
79 if ( shiftDist ) {
80 sig128 = softfloat_shortShiftLeft128( sig64, sig0, -shiftDist );
81 sig64 = sig128.v64;
82 sig0 = sig128.v0;
83 }
84 } else {
85 /*--------------------------------------------------------------------
86 *--------------------------------------------------------------------*/
87 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
88 sigExtra = softfloat_shiftRightJam64Extra( sig64, sig0, shiftDist );
89 sig64 = sigExtra.v;
90 sig0 = sigExtra.extra;
91 }
92 return softfloat_roundToI64( sign, sig64, sig0, roundingMode, exact );
93
94}
#define i64_fromNaN
Definition specialize.h:70
#define i64_fromNegOverflow
Definition specialize.h:69
#define i64_fromPosOverflow
Definition specialize.h:68
int_fast64_t softfloat_roundToI64(bool sign, uint_fast64_t sig, uint_fast64_t sigExtra, uint_fast8_t roundingMode, bool exact)
struct uint64_extra softfloat_shiftRightJam64Extra(uint64_t a, uint64_t extra, uint_fast32_t dist)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_to_i64_r_minMag()

int_fast64_t f128_to_i64_r_minMag ( float128_t a,
bool exact )

Definition at line 44 of file f128_to_i64_r_minMag.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52 int_fast8_t negShiftDist;
53 int_fast64_t absZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 sig64 = fracF128UI64( uiA64 );
63 sig0 = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 shiftDist = 0x402F - exp;
67 if ( shiftDist < 0 ) {
68 /*--------------------------------------------------------------------
69 *--------------------------------------------------------------------*/
70 if ( shiftDist < -14 ) {
71 if (
72 (uiA64 == UINT64_C( 0xC03E000000000000 ))
73 && (sig0 < UINT64_C( 0x0002000000000000 ))
74 ) {
75 if ( exact && sig0 ) {
77 }
78 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
79 }
81 return
82 (exp == 0x7FFF) && (sig64 | sig0) ? i64_fromNaN
84 }
85 /*--------------------------------------------------------------------
86 *--------------------------------------------------------------------*/
87 sig64 |= UINT64_C( 0x0001000000000000 );
88 negShiftDist = -shiftDist;
89 absZ = sig64<<negShiftDist | sig0>>(shiftDist & 63);
90 if ( exact && (uint64_t) (sig0<<negShiftDist) ) {
92 }
93 } else {
94 /*--------------------------------------------------------------------
95 *--------------------------------------------------------------------*/
96 if ( 49 <= shiftDist ) {
97 if ( exact && (exp | sig64 | sig0) ) {
99 }
100 return 0;
101 }
102 /*--------------------------------------------------------------------
103 *--------------------------------------------------------------------*/
104 sig64 |= UINT64_C( 0x0001000000000000 );
105 absZ = sig64>>shiftDist;
106 if ( exact && (sig0 || (absZ<<shiftDist != sig64)) ) {
108 }
109 }
110 return sign ? -absZ : absZ;
111
112}
#define INT64_C(val)
Definition stdint.h:279
int8_t int_fast8_t
Definition stdint.h:150
int64_t int_fast64_t
Definition stdint.h:153
Here is the call graph for this function:

◆ f128_to_ui32()

uint_fast32_t f128_to_ui32 ( float128_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 45 of file f128_to_ui32.c.

46{
47 union ui128_f128 uA;
48 uint_fast64_t uiA64, uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig64;
52 int_fast32_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.ui.v64;
58 uiA0 = uA.ui.v0;
59 sign = signF128UI64( uiA64 );
60 exp = expF128UI64( uiA64 );
61 sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
65 if ( (exp == 0x7FFF) && sig64 ) {
66#if (ui32_fromNaN == ui32_fromPosOverflow)
67 sign = 0;
68#elif (ui32_fromNaN == ui32_fromNegOverflow)
69 sign = 1;
70#else
72 return ui32_fromNaN;
73#endif
74 }
75#endif
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
79 shiftDist = 0x4023 - exp;
80 if ( 0 < shiftDist ) {
81 sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
82 }
83 return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
84
85}
#define ui32_fromNaN
Definition specialize.h:56
uint_fast32_t softfloat_roundToUI32(bool, uint_fast64_t, uint_fast8_t, bool)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_to_ui32_r_minMag()

uint_fast32_t f128_to_ui32_r_minMag ( float128_t a,
bool exact )

Definition at line 44 of file f128_to_ui32_r_minMag.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 int_fast32_t exp;
49 uint_fast64_t sig64;
50 int_fast32_t shiftDist;
51 bool sign;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.ui.v64;
58 uiA0 = uA.ui.v0;
59 exp = expF128UI64( uiA64 );
60 sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0x402F - exp;
64 if ( 49 <= shiftDist ) {
65 if ( exact && (exp | sig64) ) {
67 }
68 return 0;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 sign = signF128UI64( uiA64 );
73 if ( sign || (shiftDist < 17) ) {
75 return
76 (exp == 0x7FFF) && sig64 ? ui32_fromNaN
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 sig64 |= UINT64_C( 0x0001000000000000 );
82 z = sig64>>shiftDist;
83 if ( exact && ((uint_fast64_t) z<<shiftDist != sig64) ) {
85 }
86 return z;
87
88}
#define ui32_fromNegOverflow
Definition specialize.h:55
#define ui32_fromPosOverflow
Definition specialize.h:54
Here is the call graph for this function:

◆ f128_to_ui64()

uint_fast64_t f128_to_ui64 ( float128_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 45 of file f128_to_ui64.c.

46{
47 union ui128_f128 uA;
48 uint_fast64_t uiA64, uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig64, sig0;
52 int_fast32_t shiftDist;
53 struct uint128 sig128;
54 struct uint64_extra sigExtra;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.ui.v64;
60 uiA0 = uA.ui.v0;
61 sign = signF128UI64( uiA64 );
62 exp = expF128UI64( uiA64 );
63 sig64 = fracF128UI64( uiA64 );
64 sig0 = uiA0;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 shiftDist = 0x402F - exp;
68 if ( shiftDist <= 0 ) {
69 /*--------------------------------------------------------------------
70 *--------------------------------------------------------------------*/
71 if ( shiftDist < -15 ) {
73 return
74 (exp == 0x7FFF) && (sig64 | sig0) ? ui64_fromNaN
76 }
77 /*--------------------------------------------------------------------
78 *--------------------------------------------------------------------*/
79 sig64 |= UINT64_C( 0x0001000000000000 );
80 if ( shiftDist ) {
81 sig128 = softfloat_shortShiftLeft128( sig64, sig0, -shiftDist );
82 sig64 = sig128.v64;
83 sig0 = sig128.v0;
84 }
85 } else {
86 /*--------------------------------------------------------------------
87 *--------------------------------------------------------------------*/
88 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
89 sigExtra = softfloat_shiftRightJam64Extra( sig64, sig0, shiftDist );
90 sig64 = sigExtra.v;
91 sig0 = sigExtra.extra;
92 }
93 return softfloat_roundToUI64( sign, sig64, sig0, roundingMode, exact );
94
95}
#define ui64_fromPosOverflow
Definition specialize.h:65
#define ui64_fromNegOverflow
Definition specialize.h:66
#define ui64_fromNaN
Definition specialize.h:67
uint_fast64_t softfloat_roundToUI64(bool sign, uint_fast64_t sig, uint_fast64_t sigExtra, uint_fast8_t roundingMode, bool exact)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128_to_ui64_r_minMag()

uint_fast64_t f128_to_ui64_r_minMag ( float128_t a,
bool exact )

Definition at line 44 of file f128_to_ui64_r_minMag.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52 int_fast8_t negShiftDist;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 sig64 = fracF128UI64( uiA64 );
63 sig0 = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 shiftDist = 0x402F - exp;
67 if ( shiftDist < 0 ) {
68 /*--------------------------------------------------------------------
69 *--------------------------------------------------------------------*/
70 if ( sign || (shiftDist < -15) ) goto invalid;
71 sig64 |= UINT64_C( 0x0001000000000000 );
72 negShiftDist = -shiftDist;
73 z = sig64<<negShiftDist | sig0>>(shiftDist & 63);
74 if ( exact && (uint64_t) (sig0<<negShiftDist) ) {
76 }
77 } else {
78 /*--------------------------------------------------------------------
79 *--------------------------------------------------------------------*/
80 if ( 49 <= shiftDist ) {
81 if ( exact && (exp | sig64 | sig0) ) {
83 }
84 return 0;
85 }
86 /*--------------------------------------------------------------------
87 *--------------------------------------------------------------------*/
88 if ( sign ) goto invalid;
89 sig64 |= UINT64_C( 0x0001000000000000 );
90 z = sig64>>shiftDist;
91 if ( exact && (sig0 || (z<<shiftDist != sig64)) ) {
93 }
94 }
95 return z;
96 /*------------------------------------------------------------------------
97 *------------------------------------------------------------------------*/
98 invalid:
100 return
101 (exp == 0x7FFF) && (sig64 | sig0) ? ui64_fromNaN
103
104}
Here is the call graph for this function:

◆ f128M_add()

void f128M_add ( const float128_t * aPtr,
const float128_t * bPtr,
float128_t * zPtr )

Definition at line 84 of file f128M_add.c.

85{
86
88 (const uint32_t *) aPtr,
89 (const uint32_t *) bPtr,
90 (uint32_t *) zPtr,
91 false
92 );
93
94}
void softfloat_addF128M(const uint32_t *, const uint32_t *, uint32_t *, bool)
Definition s_addF128M.c:45
Here is the call graph for this function:

◆ f128M_div()

void f128M_div ( const float128_t * aPtr,
const float128_t * bPtr,
float128_t * zPtr )

Definition at line 57 of file f128M_div.c.

58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr, uiA96;
61 bool signA;
62 int32_t expA;
63 uint32_t uiB96;
64 bool signB;
65 int32_t expB;
66 bool signZ;
67 uint32_t y[5], sigB[4];
68 int32_t expZ;
69 uint32_t recip32;
70 int ix;
71 uint64_t q64;
72 uint32_t q, qs[3], uiZ96;
73
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 aWPtr = (const uint32_t *) aPtr;
77 bWPtr = (const uint32_t *) bPtr;
78 zWPtr = (uint32_t *) zPtr;
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 uiA96 = aWPtr[indexWordHi( 4 )];
82 signA = signF128UI96( uiA96 );
83 expA = expF128UI96( uiA96 );
84 uiB96 = bWPtr[indexWordHi( 4 )];
85 signB = signF128UI96( uiB96 );
86 expB = expF128UI96( uiB96 );
87 signZ = signA ^ signB;
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
91 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
92 if ( expA == 0x7FFF ) {
93 if ( expB == 0x7FFF ) goto invalid;
94 goto infinity;
95 }
96 goto zero;
97 }
98 /*------------------------------------------------------------------------
99 *------------------------------------------------------------------------*/
100 expA = softfloat_shiftNormSigF128M( aWPtr, 13, y );
101 expB = softfloat_shiftNormSigF128M( bWPtr, 13, sigB );
102 if ( expA == -128 ) {
103 if ( expB == -128 ) goto invalid;
104 goto zero;
105 }
106 if ( expB == -128 ) {
108 goto infinity;
109 }
110 /*------------------------------------------------------------------------
111 *------------------------------------------------------------------------*/
112 expZ = expA - expB + 0x3FFE;
113 if ( softfloat_compare128M( y, sigB ) < 0 ) {
114 --expZ;
115 softfloat_add128M( y, y, y );
116 }
117 recip32 =
119 ((uint64_t) sigB[indexWord( 4, 3 )]<<32 | sigB[indexWord( 4, 2 )])
120 >>30
121 );
122 ix = 3;
123 for (;;) {
124 q64 = (uint64_t) y[indexWordHi( 4 )] * recip32;
125 q = (q64 + 0x80000000)>>32;
126 --ix;
127 if ( ix < 0 ) break;
128 softfloat_remStep128MBy32( y, 29, sigB, q, y );
129 if ( y[indexWordHi( 4 )] & 0x80000000 ) {
130 --q;
131 softfloat_add128M( y, sigB, y );
132 }
133 qs[ix] = q;
134 }
135 /*------------------------------------------------------------------------
136 *------------------------------------------------------------------------*/
137 if ( ((q + 1) & 7) < 2 ) {
138 softfloat_remStep128MBy32( y, 29, sigB, q, y );
139 if ( y[indexWordHi( 4 )] & 0x80000000 ) {
140 --q;
141 softfloat_add128M( y, sigB, y );
142 } else if ( softfloat_compare128M( sigB, y ) <= 0 ) {
143 ++q;
144 softfloat_sub128M( y, sigB, y );
145 }
146 if (
147 y[indexWordLo( 4 )] || y[indexWord( 4, 1 )]
148 || (y[indexWord( 4, 2 )] | y[indexWord( 4, 3 )])
149 ) {
150 q |= 1;
151 }
152 }
153 /*------------------------------------------------------------------------
154 *------------------------------------------------------------------------*/
155 q64 = (uint64_t) q<<28;
156 y[indexWord( 5, 0 )] = q64;
157 q64 = ((uint64_t) qs[0]<<25) + (q64>>32);
158 y[indexWord( 5, 1 )] = q64;
159 q64 = ((uint64_t) qs[1]<<22) + (q64>>32);
160 y[indexWord( 5, 2 )] = q64;
161 q64 = ((uint64_t) qs[2]<<19) + (q64>>32);
162 y[indexWord( 5, 3 )] = q64;
163 y[indexWord( 5, 4 )] = q64>>32;
164 softfloat_roundPackMToF128M( signZ, expZ, y, zWPtr );
165 return;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_invalidF128M( zWPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 infinity:
174 uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
175 goto uiZ96;
176 zero:
177 uiZ96 = packToF128UI96( signZ, 0, 0 );
178 uiZ96:
179 zWPtr[indexWordHi( 4 )] = uiZ96;
180 zWPtr[indexWord( 4, 2 )] = 0;
181 zWPtr[indexWord( 4, 1 )] = 0;
182 zWPtr[indexWord( 4, 0 )] = 0;
183
184}
void softfloat_invalidF128M(uint32_t *)
void softfloat_roundPackMToF128M(bool, int32_t, uint32_t *, uint32_t *)
#define packToF128UI96(sign, exp, sig96)
Definition internals.h:250
int softfloat_shiftNormSigF128M(const uint32_t *, uint_fast8_t, uint32_t *)
bool softfloat_tryPropagateNaNF128M(const uint32_t *, const uint32_t *, uint32_t *)
#define signF128UI96(a96)
Definition internals.h:247
#define expF128UI96(a96)
Definition internals.h:248
#define indexWordLo(total)
#define indexWordHi(total)
#define softfloat_add128M(aPtr, bPtr, zPtr)
Definition primitives.h:923
int_fast8_t softfloat_compare128M(const uint32_t *aPtr, const uint32_t *bPtr)
#define softfloat_remStep128MBy32(remPtr, dist, bPtr, q, zPtr)
#define softfloat_sub128M(aPtr, bPtr, zPtr)
signed int int32_t
Definition stdint.h:123
Here is the call graph for this function:

◆ f128M_eq()

bool f128M_eq ( const float128_t * aPtr,
const float128_t * bPtr )

Definition at line 55 of file f128M_eq.c.

56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t wordA, wordB, uiA96, uiB96;
59 bool possibleOppositeZeros;
60 uint32_t mashWord;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 wordA = aWPtr[indexWord( 4, 2 )];
65 wordB = bWPtr[indexWord( 4, 2 )];
66 if ( wordA != wordB ) goto false_checkSigNaNs;
67 uiA96 = aWPtr[indexWordHi( 4 )];
68 uiB96 = bWPtr[indexWordHi( 4 )];
69 possibleOppositeZeros = false;
70 if ( uiA96 != uiB96 ) {
71 possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
72 if ( ! possibleOppositeZeros ) goto false_checkSigNaNs;
73 }
74 mashWord = wordA | wordB;
75 wordA = aWPtr[indexWord( 4, 1 )];
76 wordB = bWPtr[indexWord( 4, 1 )];
77 if ( wordA != wordB ) goto false_checkSigNaNs;
78 mashWord |= wordA | wordB;
79 wordA = aWPtr[indexWord( 4, 0 )];
80 wordB = bWPtr[indexWord( 4, 0 )];
81 if ( wordA != wordB ) goto false_checkSigNaNs;
82 if ( possibleOppositeZeros && ((mashWord | wordA | wordB) != 0) ) {
83 goto false_checkSigNaNs;
84 }
85 if ( ! softfloat_isNaNF128M( aWPtr ) && ! softfloat_isNaNF128M( bWPtr ) ) {
86 return true;
87 }
88 false_checkSigNaNs:
89 if (
90 f128M_isSignalingNaN( (const float128_t *) aWPtr )
91 || f128M_isSignalingNaN( (const float128_t *) bWPtr )
92 ) {
94 }
95 return false;
96
97}
bool f128M_isSignalingNaN(const float128_t *aPtr)
bool softfloat_isNaNF128M(const uint32_t *)
Here is the call graph for this function:

◆ f128M_eq_signaling()

bool f128M_eq_signaling ( const float128_t * aPtr,
const float128_t * bPtr )

Definition at line 55 of file f128M_eq_signaling.c.

56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t wordA, wordB, uiA96, uiB96;
59 bool possibleOppositeZeros;
60 uint32_t mashWord;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
66 return false;
67 }
68 wordA = aWPtr[indexWord( 4, 2 )];
69 wordB = bWPtr[indexWord( 4, 2 )];
70 if ( wordA != wordB ) return false;
71 uiA96 = aWPtr[indexWordHi( 4 )];
72 uiB96 = bWPtr[indexWordHi( 4 )];
73 possibleOppositeZeros = false;
74 if ( uiA96 != uiB96 ) {
75 possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
76 if ( ! possibleOppositeZeros ) return false;
77 }
78 mashWord = wordA | wordB;
79 wordA = aWPtr[indexWord( 4, 1 )];
80 wordB = bWPtr[indexWord( 4, 1 )];
81 if ( wordA != wordB ) return false;
82 mashWord |= wordA | wordB;
83 wordA = aWPtr[indexWord( 4, 0 )];
84 wordB = bWPtr[indexWord( 4, 0 )];
85 return
86 (wordA == wordB)
87 && (! possibleOppositeZeros || ((mashWord | wordA | wordB) == 0));
88
89}
Here is the call graph for this function:

◆ f128M_isSignalingNaN()

bool f128M_isSignalingNaN ( const float128_t * aPtr)

Definition at line 45 of file f128M_isSignalingNaN.c.

46{
47 const uint32_t *aWPtr;
48 uint32_t uiA96;
49
50 aWPtr = (const uint32_t *) aPtr;
51 uiA96 = aWPtr[indexWordHi( 4 )];
52 if ( (uiA96 & 0x7FFF8000) != 0x7FFF0000 ) return false;
53 return
54 ((uiA96 & 0x00007FFF) != 0)
55 || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
56 | aWPtr[indexWord( 4, 0 )])
57 != 0);
58
59}
Here is the caller graph for this function:

◆ f128M_le()

bool f128M_le ( const float128_t * aPtr,
const float128_t * bPtr )

Definition at line 54 of file f128M_le.c.

55{
56 const uint32_t *aWPtr, *bWPtr;
57 uint32_t uiA96, uiB96;
58 bool signA, signB;
59 uint32_t wordA, wordB;
60
61 aWPtr = (const uint32_t *) aPtr;
62 bWPtr = (const uint32_t *) bPtr;
63 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
65 return false;
66 }
67 uiA96 = aWPtr[indexWordHi( 4 )];
68 uiB96 = bWPtr[indexWordHi( 4 )];
69 signA = signF128UI96( uiA96 );
70 signB = signF128UI96( uiB96 );
71 if ( signA != signB ) {
72 if ( signA ) return true;
73 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
74 wordA = aWPtr[indexWord( 4, 2 )];
75 wordB = bWPtr[indexWord( 4, 2 )];
76 if ( wordA | wordB ) return false;
77 wordA = aWPtr[indexWord( 4, 1 )];
78 wordB = bWPtr[indexWord( 4, 1 )];
79 if ( wordA | wordB ) return false;
80 wordA = aWPtr[indexWord( 4, 0 )];
81 wordB = bWPtr[indexWord( 4, 0 )];
82 return ((wordA | wordB) == 0);
83 }
84 if ( signA ) {
85 aWPtr = (const uint32_t *) bPtr;
86 bWPtr = (const uint32_t *) aPtr;
87 }
88 return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
89
90}
Here is the call graph for this function:

◆ f128M_le_quiet()

bool f128M_le_quiet ( const float128_t * aPtr,
const float128_t * bPtr )

Definition at line 55 of file f128M_le_quiet.c.

56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t uiA96, uiB96;
59 bool signA, signB;
60 uint32_t wordA, wordB;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
65 if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
67 }
68 return false;
69 }
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 uiB96 = bWPtr[indexWordHi( 4 )];
72 signA = signF128UI96( uiA96 );
73 signB = signF128UI96( uiB96 );
74 if ( signA != signB ) {
75 if ( signA ) return true;
76 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
77 wordA = aWPtr[indexWord( 4, 2 )];
78 wordB = bWPtr[indexWord( 4, 2 )];
79 if ( wordA | wordB ) return false;
80 wordA = aWPtr[indexWord( 4, 1 )];
81 wordB = bWPtr[indexWord( 4, 1 )];
82 if ( wordA | wordB ) return false;
83 wordA = aWPtr[indexWord( 4, 0 )];
84 wordB = bWPtr[indexWord( 4, 0 )];
85 return ((wordA | wordB) == 0);
86 }
87 if ( signA ) {
88 aWPtr = (const uint32_t *) bPtr;
89 bWPtr = (const uint32_t *) aPtr;
90 }
91 return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
92
93}
Here is the call graph for this function:

◆ f128M_lt()

bool f128M_lt ( const float128_t * aPtr,
const float128_t * bPtr )

Definition at line 54 of file f128M_lt.c.

55{
56 const uint32_t *aWPtr, *bWPtr;
57 uint32_t uiA96, uiB96;
58 bool signA, signB;
59 uint32_t wordA, wordB;
60
61 aWPtr = (const uint32_t *) aPtr;
62 bWPtr = (const uint32_t *) bPtr;
63 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
65 return false;
66 }
67 uiA96 = aWPtr[indexWordHi( 4 )];
68 uiB96 = bWPtr[indexWordHi( 4 )];
69 signA = signF128UI96( uiA96 );
70 signB = signF128UI96( uiB96 );
71 if ( signA != signB ) {
72 if ( signB ) return false;
73 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
74 wordA = aWPtr[indexWord( 4, 2 )];
75 wordB = bWPtr[indexWord( 4, 2 )];
76 if ( wordA | wordB ) return true;
77 wordA = aWPtr[indexWord( 4, 1 )];
78 wordB = bWPtr[indexWord( 4, 1 )];
79 if ( wordA | wordB ) return true;
80 wordA = aWPtr[indexWord( 4, 0 )];
81 wordB = bWPtr[indexWord( 4, 0 )];
82 return ((wordA | wordB) != 0);
83 }
84 if ( signA ) {
85 aWPtr = (const uint32_t *) bPtr;
86 bWPtr = (const uint32_t *) aPtr;
87 }
88 return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
89
90}
Here is the call graph for this function:

◆ f128M_lt_quiet()

bool f128M_lt_quiet ( const float128_t * aPtr,
const float128_t * bPtr )

Definition at line 55 of file f128M_lt_quiet.c.

56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t uiA96, uiB96;
59 bool signA, signB;
60 uint32_t wordA, wordB;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
65 if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
67 }
68 return false;
69 }
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 uiB96 = bWPtr[indexWordHi( 4 )];
72 signA = signF128UI96( uiA96 );
73 signB = signF128UI96( uiB96 );
74 if ( signA != signB ) {
75 if ( signB ) return false;
76 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
77 wordA = aWPtr[indexWord( 4, 2 )];
78 wordB = bWPtr[indexWord( 4, 2 )];
79 if ( wordA | wordB ) return true;
80 wordA = aWPtr[indexWord( 4, 1 )];
81 wordB = bWPtr[indexWord( 4, 1 )];
82 if ( wordA | wordB ) return true;
83 wordA = aWPtr[indexWord( 4, 0 )];
84 wordB = bWPtr[indexWord( 4, 0 )];
85 return ((wordA | wordB) != 0);
86 }
87 if ( signA ) {
88 aWPtr = (const uint32_t *) bPtr;
89 bWPtr = (const uint32_t *) aPtr;
90 }
91 return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
92
93}
Here is the call graph for this function:

◆ f128M_mul()

void f128M_mul ( const float128_t * aPtr,
const float128_t * bPtr,
float128_t * zPtr )

Definition at line 57 of file f128M_mul.c.

58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr;
61 uint32_t uiA96;
62 int32_t expA;
63 uint32_t uiB96;
64 int32_t expB;
65 bool signZ;
66 const uint32_t *ptr;
67 uint32_t uiZ96, sigA[4];
68 uint_fast8_t shiftDist;
69 uint32_t sigB[4];
70 int32_t expZ;
71 uint32_t sigProd[8], *extSigZPtr;
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 aWPtr = (const uint32_t *) aPtr;
76 bWPtr = (const uint32_t *) bPtr;
77 zWPtr = (uint32_t *) zPtr;
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 uiA96 = aWPtr[indexWordHi( 4 )];
81 expA = expF128UI96( uiA96 );
82 uiB96 = bWPtr[indexWordHi( 4 )];
83 expB = expF128UI96( uiB96 );
84 signZ = signF128UI96( uiA96 ) ^ signF128UI96( uiB96 );
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
88 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
89 ptr = aWPtr;
90 if ( ! expA ) goto possiblyInvalid;
91 if ( ! expB ) {
92 ptr = bWPtr;
93 possiblyInvalid:
94 if (
95 ! fracF128UI96( ptr[indexWordHi( 4 )] )
96 && ! (ptr[indexWord( 4, 2 )] | ptr[indexWord( 4, 1 )]
97 | ptr[indexWord( 4, 0 )])
98 ) {
100 return;
101 }
102 }
103 uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
104 goto uiZ96;
105 }
106 /*------------------------------------------------------------------------
107 *------------------------------------------------------------------------*/
108 if ( expA ) {
109 sigA[indexWordHi( 4 )] = fracF128UI96( uiA96 ) | 0x00010000;
110 sigA[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
111 sigA[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
112 sigA[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
113 } else {
114 expA = softfloat_shiftNormSigF128M( aWPtr, 0, sigA );
115 if ( expA == -128 ) goto zero;
116 }
117 if ( expB ) {
118 sigB[indexWordHi( 4 )] = fracF128UI96( uiB96 ) | 0x00010000;
119 sigB[indexWord( 4, 2 )] = bWPtr[indexWord( 4, 2 )];
120 sigB[indexWord( 4, 1 )] = bWPtr[indexWord( 4, 1 )];
121 sigB[indexWord( 4, 0 )] = bWPtr[indexWord( 4, 0 )];
122 } else {
123 expB = softfloat_shiftNormSigF128M( bWPtr, 0, sigB );
124 if ( expB == -128 ) goto zero;
125 }
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 expZ = expA + expB - 0x4000;
129 softfloat_mul128MTo256M( sigA, sigB, sigProd );
130 if (
131 sigProd[indexWord( 8, 2 )]
132 || (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
133 ) {
134 sigProd[indexWord( 8, 3 )] |= 1;
135 }
136 extSigZPtr = &sigProd[indexMultiwordHi( 8, 5 )];
137 shiftDist = 16;
138 if ( extSigZPtr[indexWordHi( 5 )] & 2 ) {
139 ++expZ;
140 shiftDist = 15;
141 }
142 softfloat_shortShiftLeft160M( extSigZPtr, shiftDist, extSigZPtr );
143 softfloat_roundPackMToF128M( signZ, expZ, extSigZPtr, zWPtr );
144 return;
145 /*------------------------------------------------------------------------
146 *------------------------------------------------------------------------*/
147 zero:
148 uiZ96 = packToF128UI96( signZ, 0, 0 );
149 uiZ96:
150 zWPtr[indexWordHi( 4 )] = uiZ96;
151 zWPtr[indexWord( 4, 2 )] = 0;
152 zWPtr[indexWord( 4, 1 )] = 0;
153 zWPtr[indexWord( 4, 0 )] = 0;
154
155}
#define fracF128UI96(a96)
Definition internals.h:249
#define indexMultiwordHi(total, n)
void softfloat_mul128MTo256M(const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr)
#define softfloat_shortShiftLeft160M(aPtr, dist, zPtr)
Definition primitives.h:711
uint8_t uint_fast8_t
Definition stdint.h:154
Here is the call graph for this function:

◆ f128M_mulAdd()

void f128M_mulAdd ( const float128_t * aPtr,
const float128_t * bPtr,
const float128_t * cPtr,
float128_t * zPtr )

Definition at line 73 of file f128M_mulAdd.c.

79{
80
82 (const uint32_t *) aPtr,
83 (const uint32_t *) bPtr,
84 (const uint32_t *) cPtr,
85 (uint32_t *) zPtr,
86 0
87 );
88
89}
void softfloat_mulAddF128M(const uint32_t *, const uint32_t *, const uint32_t *, uint32_t *, uint_fast8_t)
Here is the call graph for this function:

◆ f128M_rem()

void f128M_rem ( const float128_t * aPtr,
const float128_t * bPtr,
float128_t * zPtr )

Definition at line 57 of file f128M_rem.c.

58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr, uiA96;
61 int32_t expA, expB;
62 uint32_t x[4], rem1[5], *remPtr;
63 bool signRem;
64 int32_t expDiff;
65 uint32_t q, recip32;
66 uint64_t q64;
67 uint32_t rem2[5], *altRemPtr, *newRemPtr, wordMeanRem;
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 aWPtr = (const uint32_t *) aPtr;
72 bWPtr = (const uint32_t *) bPtr;
73 zWPtr = (uint32_t *) zPtr;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 uiA96 = aWPtr[indexWordHi( 4 )];
77 expA = expF128UI96( uiA96 );
78 expB = expF128UI96( bWPtr[indexWordHi( 4 )] );
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
82 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
83 if ( expA == 0x7FFF ) goto invalid;
84 goto copyA;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( expA < expB - 1 ) goto copyA;
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 expB = softfloat_shiftNormSigF128M( bWPtr, 13, x );
92 if ( expB == -128 ) goto invalid;
93 remPtr = &rem1[indexMultiwordLo( 5, 4 )];
94 expA = softfloat_shiftNormSigF128M( aWPtr, 13, remPtr );
95 if ( expA == -128 ) goto copyA;
96 signRem = signF128UI96( uiA96 );
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 expDiff = expA - expB;
100 if ( expDiff < 1 ) {
101 if ( expDiff < -1 ) goto copyA;
102 if ( expDiff ) {
103 --expB;
104 softfloat_add128M( x, x, x );
105 q = 0;
106 } else {
107 q = (softfloat_compare128M( x, remPtr ) <= 0);
108 if ( q ) softfloat_sub128M( remPtr, x, remPtr );
109 }
110 } else {
111 recip32 =
113 ((uint64_t) x[indexWord( 4, 3 )]<<32 | x[indexWord( 4, 2 )])
114 >>30
115 );
116 expDiff -= 30;
117 for (;;) {
118 q64 = (uint64_t) remPtr[indexWordHi( 4 )] * recip32;
119 if ( expDiff < 0 ) break;
120 q = (q64 + 0x80000000)>>32;
121 softfloat_remStep128MBy32( remPtr, 29, x, q, remPtr );
122 if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
123 softfloat_add128M( remPtr, x, remPtr );
124 }
125 expDiff -= 29;
126 }
127 /*--------------------------------------------------------------------
128 | (`expDiff' cannot be less than -29 here.)
129 *--------------------------------------------------------------------*/
130 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
131 softfloat_remStep128MBy32( remPtr, expDiff + 30, x, q, remPtr );
132 if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
133 altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
134 softfloat_add128M( remPtr, x, altRemPtr );
135 goto selectRem;
136 }
137 }
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
141 do {
142 ++q;
143 newRemPtr = altRemPtr;
144 softfloat_sub128M( remPtr, x, newRemPtr );
145 altRemPtr = remPtr;
146 remPtr = newRemPtr;
147 } while ( ! (remPtr[indexWordHi( 4 )] & 0x80000000) );
148 selectRem:
149 softfloat_add128M( remPtr, altRemPtr, x );
150 wordMeanRem = x[indexWordHi( 4 )];
151 if (
152 (wordMeanRem & 0x80000000)
153 || (! wordMeanRem && (q & 1) && ! x[indexWord( 4, 0 )]
154 && ! (x[indexWord( 4, 2 )] | x[indexWord( 4, 1 )]))
155 ) {
156 remPtr = altRemPtr;
157 }
158 if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
159 signRem = ! signRem;
160 softfloat_negX128M( remPtr );
161 }
162 remPtr -= indexMultiwordLo( 5, 4 );
163 remPtr[indexWordHi( 5 )] = 0;
164 softfloat_normRoundPackMToF128M( signRem, expB + 18, remPtr, zWPtr );
165 return;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_invalidF128M( zWPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 copyA:
174 zWPtr[indexWordHi( 4 )] = uiA96;
175 zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
176 zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
177 zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
178
179}
void softfloat_normRoundPackMToF128M(bool, int32_t, uint32_t *, uint32_t *)
#define indexMultiwordLo(total, n)
#define softfloat_negX128M(zPtr)
Here is the call graph for this function:

◆ f128M_roundToInt()

void f128M_roundToInt ( const float128_t * aPtr,
uint_fast8_t roundingMode,
bool exact,
float128_t * zPtr )

Definition at line 62 of file f128M_roundToInt.c.

68{
69 const uint32_t *aWPtr;
70 uint32_t *zWPtr;
71 uint32_t ui96;
72 int32_t exp;
73 uint32_t sigExtra;
74 bool sign;
75 uint_fast8_t bitPos;
76 bool roundNear;
77 unsigned int index, lastIndex;
78 bool extra;
79 uint32_t wordA, bit, wordZ;
80 uint_fast8_t carry;
81 uint32_t extrasMask;
82
83 /*------------------------------------------------------------------------
84 *------------------------------------------------------------------------*/
85 aWPtr = (const uint32_t *) aPtr;
86 zWPtr = (uint32_t *) zPtr;
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 ui96 = aWPtr[indexWordHi( 4 )];
90 exp = expF128UI96( ui96 );
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 if ( exp < 0x3FFF ) {
94 zWPtr[indexWord( 4, 2 )] = 0;
95 zWPtr[indexWord( 4, 1 )] = 0;
96 zWPtr[indexWord( 4, 0 )] = 0;
97 sigExtra = aWPtr[indexWord( 4, 2 )];
98 if ( !sigExtra ) {
99 sigExtra = aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )];
100 }
101 if ( !sigExtra && !(ui96 & 0x7FFFFFFF) ) goto ui96;
103 sign = signF128UI96( ui96 );
104 switch ( roundingMode ) {
106 if ( !fracF128UI96( ui96 ) && !sigExtra ) break;
108 if ( exp == 0x3FFE ) goto mag1;
109 break;
111 if ( sign ) goto mag1;
112 break;
114 if ( !sign ) goto mag1;
115 break;
116#ifdef SOFTFLOAT_ROUND_ODD
118 goto mag1;
119#endif
120 }
121 ui96 = packToF128UI96( sign, 0, 0 );
122 goto ui96;
123 mag1:
124 ui96 = packToF128UI96( sign, 0x3FFF, 0 );
125 goto ui96;
126 }
127 /*------------------------------------------------------------------------
128 *------------------------------------------------------------------------*/
129 if ( 0x406F <= exp ) {
130 if (
131 (exp == 0x7FFF)
132 && (fracF128UI96( ui96 )
133 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
134 | aWPtr[indexWord( 4, 0 )]))
135 ) {
136 softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
137 return;
138 }
139 zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
140 zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
141 zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
142 goto ui96;
143 }
144 /*------------------------------------------------------------------------
145 *------------------------------------------------------------------------*/
146 bitPos = 0x406F - exp;
147 roundNear =
148 (roundingMode == softfloat_round_near_maxMag)
149 || (roundingMode == softfloat_round_near_even);
150 bitPos -= roundNear;
151 index = indexWordLo( 4 );
152 lastIndex = indexWordHi( 4 );
153 extra = 0;
154 for (;;) {
155 wordA = aWPtr[index];
156 if ( bitPos < 32 ) break;
157 if ( wordA ) extra = 1;
158 zWPtr[index] = 0;
159 index += wordIncr;
160 bitPos -= 32;
161 }
162 bit = (uint32_t) 1<<bitPos;
163 if ( roundNear ) {
164 wordZ = wordA + bit;
165 carry = (wordZ < wordA);
166 bit <<= 1;
167 extrasMask = bit - 1;
168 if ( exact && (extra || (wordA & extrasMask)) ) {
170 }
171 if (
172 (roundingMode == softfloat_round_near_even)
173 && !extra && !(wordZ & extrasMask)
174 ) {
175 if ( !bit ) {
176 zWPtr[index] = wordZ;
177 index += wordIncr;
178 wordZ = aWPtr[index] + carry;
179 carry &= !wordZ;
180 zWPtr[index] = wordZ & ~1;
181 goto propagateCarry;
182 }
183 wordZ &= ~bit;
184 }
185 } else {
186 wordZ = wordA;
187 carry = 0;
188 extrasMask = bit - 1;
189 if ( extra || (wordA & extrasMask) ) {
191 if (
192 roundingMode
195 ) {
196 wordZ += bit;
197 carry = (wordZ < wordA);
198#ifdef SOFTFLOAT_ROUND_ODD
199 } else if ( roundingMode == softfloat_round_odd ) {
200 wordZ |= bit;
201#endif
202 }
203 }
204 }
205 wordZ &= ~extrasMask;
206 zWPtr[index] = wordZ;
207 propagateCarry:
208 while ( index != lastIndex ) {
209 index += wordIncr;
210 wordZ = aWPtr[index] + carry;
211 zWPtr[index] = wordZ;
212 carry &= !wordZ;
213 }
214 return;
215 /*------------------------------------------------------------------------
216 *------------------------------------------------------------------------*/
217 ui96:
218 zWPtr[indexWordHi( 4 )] = ui96;
219
220}
void softfloat_propagateNaNF128M(const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr)
#define wordIncr
int bit
Definition yubihsm.h:566
Here is the call graph for this function:

◆ f128M_sqrt()

void f128M_sqrt ( const float128_t * aPtr,
float128_t * zPtr )

Definition at line 55 of file f128M_sqrt.c.

56{
57 const uint32_t *aWPtr;
58 uint32_t *zWPtr;
59 uint32_t uiA96;
60 bool signA;
61 int32_t rawExpA;
62 uint32_t rem[6];
63 int32_t expA, expZ;
64 uint64_t rem64;
65 uint32_t sig32A, recipSqrt32, sig32Z, qs[3], q;
66 uint64_t sig64Z;
67 uint32_t term[5];
68 uint64_t x64;
69 uint32_t y[5], rem32;
70
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 aWPtr = (const uint32_t *) aPtr;
74 zWPtr = (uint32_t *) zPtr;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 uiA96 = aWPtr[indexWordHi( 4 )];
78 signA = signF128UI96( uiA96 );
79 rawExpA = expF128UI96( uiA96 );
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 if ( rawExpA == 0x7FFF ) {
83 if (
84 fracF128UI96( uiA96 )
85 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
86 | aWPtr[indexWord( 4, 0 )])
87 ) {
88 softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
89 return;
90 }
91 if ( ! signA ) goto copyA;
92 goto invalid;
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 expA = softfloat_shiftNormSigF128M( aWPtr, 13 - (rawExpA & 1), rem );
97 if ( expA == -128 ) goto copyA;
98 if ( signA ) goto invalid;
99 /*------------------------------------------------------------------------
100 | (`sig32Z' is guaranteed to be a lower bound on the square root of
101 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
102 | `sigA'.)
103 *------------------------------------------------------------------------*/
104 expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
105 expA &= 1;
106 rem64 = (uint64_t) rem[indexWord( 4, 3 )]<<32 | rem[indexWord( 4, 2 )];
107 if ( expA ) {
108 if ( ! rawExpA ) {
109 softfloat_shortShiftRight128M( rem, 1, rem );
110 rem64 >>= 1;
111 }
112 sig32A = rem64>>29;
113 } else {
114 sig32A = rem64>>30;
115 }
116 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
117 sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
118 if ( expA ) sig32Z >>= 1;
119 qs[2] = sig32Z;
120 rem64 -= (uint64_t) sig32Z * sig32Z;
121 rem[indexWord( 4, 3 )] = rem64>>32;
122 rem[indexWord( 4, 2 )] = rem64;
123 /*------------------------------------------------------------------------
124 *------------------------------------------------------------------------*/
125 q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
126 sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
127 term[indexWord( 4, 3 )] = 0;
128 term[indexWord( 4, 0 )] = 0;
129 /*------------------------------------------------------------------------
130 | (Repeating this loop is a rare occurrence.)
131 *------------------------------------------------------------------------*/
132 for (;;) {
133 x64 = ((uint64_t) sig32Z<<32) + sig64Z;
134 term[indexWord( 4, 2 )] = x64>>32;
135 term[indexWord( 4, 1 )] = x64;
136 softfloat_remStep128MBy32( rem, 29, term, q, y );
137 rem32 = y[indexWord( 4, 3 )];
138 if ( ! (rem32 & 0x80000000) ) break;
139 --q;
140 sig64Z -= 1<<3;
141 }
142 qs[1] = q;
143 rem64 = (uint64_t) rem32<<32 | y[indexWord( 4, 2 )];
144 /*------------------------------------------------------------------------
145 *------------------------------------------------------------------------*/
146 q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
147 if ( rem64>>34 ) q += recipSqrt32;
148 sig64Z <<= 1;
149 /*------------------------------------------------------------------------
150 | (Repeating this loop is a rare occurrence.)
151 *------------------------------------------------------------------------*/
152 for (;;) {
153 x64 = sig64Z + (q>>26);
154 term[indexWord( 4, 2 )] = x64>>32;
155 term[indexWord( 4, 1 )] = x64;
156 term[indexWord( 4, 0 )] = q<<6;
158 y, 29, term, q, &rem[indexMultiwordHi( 6, 4 )] );
159 rem32 = rem[indexWordHi( 6 )];
160 if ( ! (rem32 & 0x80000000) ) break;
161 --q;
162 }
163 qs[0] = q;
164 rem64 = (uint64_t) rem32<<32 | rem[indexWord( 6, 4 )];
165 /*------------------------------------------------------------------------
166 *------------------------------------------------------------------------*/
167 q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
168 if ( rem64>>34 ) q += recipSqrt32;
169 x64 = (uint64_t) q<<27;
170 y[indexWord( 5, 0 )] = x64;
171 x64 = ((uint64_t) qs[0]<<24) + (x64>>32);
172 y[indexWord( 5, 1 )] = x64;
173 x64 = ((uint64_t) qs[1]<<21) + (x64>>32);
174 y[indexWord( 5, 2 )] = x64;
175 x64 = ((uint64_t) qs[2]<<18) + (x64>>32);
176 y[indexWord( 5, 3 )] = x64;
177 y[indexWord( 5, 4 )] = x64>>32;
178 /*------------------------------------------------------------------------
179 *------------------------------------------------------------------------*/
180 if ( (q & 0xF) <= 2 ) {
181 q &= ~3;
182 y[indexWordLo( 5 )] = q<<27;
183 term[indexWord( 5, 4 )] = 0;
184 term[indexWord( 5, 3 )] = 0;
185 term[indexWord( 5, 2 )] = 0;
186 term[indexWord( 5, 1 )] = q>>6;
187 term[indexWord( 5, 0 )] = q<<26;
188 softfloat_sub160M( y, term, term );
189 rem[indexWord( 6, 1 )] = 0;
190 rem[indexWord( 6, 0 )] = 0;
192 &rem[indexMultiwordLo( 6, 5 )],
193 14,
194 term,
195 q,
196 &rem[indexMultiwordLo( 6, 5 )]
197 );
198 rem32 = rem[indexWord( 6, 4 )];
199 if ( rem32 & 0x80000000 ) {
201 } else {
202 if (
203 rem32 || rem[indexWord( 6, 0 )] || rem[indexWord( 6, 1 )]
204 || (rem[indexWord( 6, 3 )] | rem[indexWord( 6, 2 )])
205 ) {
206 y[indexWordLo( 5 )] |= 1;
207 }
208 }
209 }
210 softfloat_roundPackMToF128M( 0, expZ, y, zWPtr );
211 return;
212 /*------------------------------------------------------------------------
213 *------------------------------------------------------------------------*/
214 invalid:
215 softfloat_invalidF128M( zWPtr );
216 return;
217 /*------------------------------------------------------------------------
218 *------------------------------------------------------------------------*/
219 copyA:
220 zWPtr[indexWordHi( 4 )] = uiA96;
221 zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
222 zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
223 zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
224
225}
#define softfloat_sub1X160M(zPtr)
#define softfloat_sub160M(aPtr, bPtr, zPtr)
#define softfloat_remStep160MBy32(remPtr, dist, bPtr, q, zPtr)
#define softfloat_shortShiftRight128M(aPtr, dist, zPtr)
Definition primitives.h:782
Here is the call graph for this function:

◆ f128M_sub()

void f128M_sub ( const float128_t * aPtr,
const float128_t * bPtr,
float128_t * zPtr )

Definition at line 84 of file f128M_sub.c.

85{
86
88 (const uint32_t *) aPtr,
89 (const uint32_t *) bPtr,
90 (uint32_t *) zPtr,
91 true
92 );
93
94}
Here is the call graph for this function:

◆ f128M_to_extF80M()

void f128M_to_extF80M ( const float128_t * aPtr,
extFloat80_t * zPtr )

Definition at line 55 of file f128M_to_extF80M.c.

56{
57 const uint32_t *aWPtr;
58 struct extFloat80M *zSPtr;
59 uint32_t uiA96;
60 bool sign;
61 int32_t exp;
62 struct commonNaN commonNaN;
63 uint32_t sig[4];
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 aWPtr = (const uint32_t *) aPtr;
68 zSPtr = (struct extFloat80M *) zPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA96 = aWPtr[indexWordHi( 4 )];
72 sign = signF128UI96( uiA96 );
73 exp = expF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp == 0x7FFF ) {
77 if ( softfloat_isNaNF128M( aWPtr ) ) {
80 return;
81 }
82 zSPtr->signExp = packToExtF80UI64( sign, 0x7FFF );
83 zSPtr->signif = UINT64_C( 0x8000000000000000 );
84 return;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 exp = softfloat_shiftNormSigF128M( aWPtr, 15, sig );
89 if ( exp == -128 ) {
90 zSPtr->signExp = packToExtF80UI64( sign, 0 );
91 zSPtr->signif = 0;
92 return;
93 }
94 if ( sig[indexWord( 4, 0 )] ) sig[indexWord( 4, 1 )] |= 1;
96 sign, exp, &sig[indexMultiwordHi( 4, 3 )], 80, zSPtr );
97
98}
#define softfloat_commonNaNToExtF80M
#define softfloat_f128MToCommonNaN(aWPtr, zPtr)
Definition specialize.h:369
#define packToExtF80UI64(sign, exp)
Definition internals.h:148
void softfloat_roundPackMToExtF80M(bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M *)
uint64_t signif
uint16_t signExp
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128M_to_f16()

float16_t f128M_to_f16 ( const float128_t * aPtr)

Definition at line 55 of file f128M_to_f16.c.

56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint32_t frac32;
62 struct commonNaN commonNaN;
63 uint16_t uiZ, frac16;
64 union ui16_f16 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA96 = aWPtr[indexWordHi( 4 )];
72 sign = signF128UI96( uiA96 );
73 exp = expF128UI96( uiA96 );
74 frac32 =
75 fracF128UI96( uiA96 )
76 | ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
77 | aWPtr[indexWord( 4, 0 )])
78 != 0);
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( exp == 0x7FFF ) {
82 if ( frac32 ) {
85 } else {
86 uiZ = packToF16UI( sign, 0x1F, 0 );
87 }
88 goto uiZ;
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 frac16 = frac32>>2 | (frac32 & 3);
93 if ( ! (exp | frac16) ) {
94 uiZ = packToF16UI( sign, 0, 0 );
95 goto uiZ;
96 }
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 exp -= 0x3FF1;
100 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
101 if ( exp < -0x40 ) exp = -0x40;
102 }
103 return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
104 /*------------------------------------------------------------------------
105 *------------------------------------------------------------------------*/
106 uiZ:
107 uZ.ui = uiZ;
108 return uZ.f;
109
110}
unsigned short uint16_t
Definition stdint.h:125
Here is the call graph for this function:

◆ f128M_to_f32()

float32_t f128M_to_f32 ( const float128_t * aPtr)

Definition at line 55 of file f128M_to_f32.c.

56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint64_t frac64;
62 struct commonNaN commonNaN;
63 uint32_t uiZ, frac32;
64 union ui32_f32 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 frac64 =
73 (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )]
74 | ((aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )]) != 0);
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp == 0x7FFF ) {
78 if ( frac64 ) {
81 } else {
82 uiZ = packToF32UI( sign, 0xFF, 0 );
83 }
84 goto uiZ;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
89 if ( ! (exp | frac32) ) {
90 uiZ = packToF32UI( sign, 0, 0 );
91 goto uiZ;
92 }
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 exp -= 0x3F81;
96 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
97 if ( exp < -0x1000 ) exp = -0x1000;
98 }
99 return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 uiZ:
103 uZ.ui = uiZ;
104 return uZ.f;
105
106}
Here is the call graph for this function:

◆ f128M_to_f64()

float64_t f128M_to_f64 ( const float128_t * aPtr)

Definition at line 55 of file f128M_to_f64.c.

56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint64_t frac64;
62 struct commonNaN commonNaN;
63 uint64_t uiZ;
64 uint32_t frac32;
65 union ui64_f64 uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 frac64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp == 0x7FFF ) {
77 if ( frac64 || aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) {
80 } else {
81 uiZ = packToF64UI( sign, 0x7FF, 0 );
82 }
83 goto uiZ;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 frac32 = aWPtr[indexWord( 4, 1 )];
88 frac64 = frac64<<14 | frac32>>18;
89 if ( (frac32 & 0x0003FFFF) || aWPtr[indexWord( 4, 0 )] ) frac64 |= 1;
90 if ( ! (exp | frac64) ) {
91 uiZ = packToF64UI( sign, 0, 0 );
92 goto uiZ;
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 exp -= 0x3C01;
97 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
98 if ( exp < -0x1000 ) exp = -0x1000;
99 }
100 return
102 sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 uiZ:
106 uZ.ui = uiZ;
107 return uZ.f;
108
109}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f128M_to_i32()

int_fast32_t f128M_to_i32 ( const float128_t * aPtr,
uint_fast8_t roundingMode,
bool exact )

Definition at line 57 of file f128M_to_i32.c.

58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint64_t sig64;
64 int32_t shiftDist;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
73 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
77 if ( (exp == 0x7FFF) && sig64 ) {
78#if (i32_fromNaN == i32_fromPosOverflow)
79 sign = 0;
80#elif (i32_fromNaN == i32_fromNegOverflow)
81 sign = 1;
82#else
84 return i32_fromNaN;
85#endif
86 }
87#endif
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
91 shiftDist = 0x4023 - exp;
92 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
93 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
94
95}
Here is the call graph for this function:

◆ f128M_to_i32_r_minMag()

int_fast32_t f128M_to_i32_r_minMag ( const float128_t * aPtr,
bool exact )

Definition at line 55 of file f128M_to_i32_r_minMag.c.

56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint64_t sig64;
62 int32_t shiftDist;
63 uint32_t absZ, uiZ;
64 union { uint32_t ui; int32_t i; } uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
73 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp < 0x3FFF ) {
77 if ( exact && (exp | sig64) ) {
79 }
80 return 0;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( 0x401F <= exp ) goto invalid;
85 shiftDist = 0x402F - exp;
86 sig64 |= UINT64_C( 0x0001000000000000 );
87 absZ = sig64>>shiftDist;
88 uiZ = sign ? -absZ : absZ;
89 if ( uiZ>>31 != sign ) goto invalid;
90 if ( exact && ((uint64_t) absZ<<shiftDist != sig64) ) {
92 }
93 uZ.ui = uiZ;
94 return uZ.i;
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 invalid:
99 return
100 (exp == 0x7FFF) && sig64 ? i32_fromNaN
102
103}
Here is the call graph for this function:

◆ f128M_to_i64()

int_fast64_t f128M_to_i64 ( const float128_t * aPtr,
uint_fast8_t roundingMode,
bool exact )

Definition at line 57 of file f128M_to_i64.c.

58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint32_t sig96;
64 int32_t shiftDist;
65 uint32_t sig[4];
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 sig96 = fracF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 shiftDist = 0x404F - exp;
77 if ( shiftDist < 17 ) {
79 return
80 (exp == 0x7FFF)
81 && (sig96
82 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
83 | aWPtr[indexWord( 4, 0 )]))
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( exp ) sig96 |= 0x00010000;
90 sig[indexWord( 4, 3 )] = sig96;
91 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
92 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
93 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
94 softfloat_shiftRightJam128M( sig, shiftDist, sig );
95 return
97 sign, sig + indexMultiwordLo( 4, 3 ), roundingMode, exact );
98
99}
int_fast64_t softfloat_roundMToI64(bool, uint32_t *, uint_fast8_t, bool)
#define softfloat_shiftRightJam128M(aPtr, dist, zPtr)
Definition primitives.h:881
Here is the call graph for this function:

◆ f128M_to_i64_r_minMag()

int_fast64_t f128M_to_i64_r_minMag ( const float128_t * aPtr,
bool exact )

Definition at line 55 of file f128M_to_i64_r_minMag.c.

56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint32_t sig96;
62 int32_t shiftDist;
63 uint32_t sig[4];
64 uint64_t uiZ;
65 union { uint64_t ui; int64_t i; } uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 sig96 = fracF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 shiftDist = 0x403E - exp;
77 if ( shiftDist < 0 ) goto invalid;
78 if ( exact ) {
79 if ( exp ) sig96 |= 0x00010000;
80 sig[indexWord( 4, 3 )] = sig96;
81 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
82 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
83 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
84 softfloat_shiftRightJam128M( sig, shiftDist + 17, sig );
85 uiZ = (uint64_t) sig[indexWord( 4, 2 )]<<32 | sig[indexWord( 4, 1 )];
86 if ( uiZ>>63 && (! sign || (uiZ != UINT64_C( 0x8000000000000000 ))) ) {
87 goto invalid;
88 }
89 if ( sig[indexWordLo( 4 )] ) {
91 }
92 } else {
93 if ( 64 <= shiftDist ) return 0;
94 uiZ =
95 (uint64_t) sig96<<47
96 | (uint64_t) aWPtr[indexWord( 4, 2 )]<<15
97 | aWPtr[indexWord( 4, 1 )]>>17;
98 if ( shiftDist ) {
99 uiZ |= UINT64_C( 0x8000000000000000 );
100 uiZ >>= shiftDist;
101 } else {
102 if ( uiZ || ! sign ) goto invalid;
103 uiZ |= UINT64_C( 0x8000000000000000 );
104 }
105 }
106 if ( sign ) uiZ = -uiZ;
107 uZ.ui = uiZ;
108 return uZ.i;
109 /*------------------------------------------------------------------------
110 *------------------------------------------------------------------------*/
111 invalid:
113 return
114 (exp == 0x7FFF)
115 && (sig96
116 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
117 | aWPtr[indexWord( 4, 0 )]))
120
121}
signed __int64 int64_t
Definition stdint.h:135
Here is the call graph for this function:

◆ f128M_to_ui32()

uint_fast32_t f128M_to_ui32 ( const float128_t * aPtr,
uint_fast8_t roundingMode,
bool exact )

Definition at line 57 of file f128M_to_ui32.c.

58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint64_t sig64;
64 int32_t shiftDist;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
73 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
77 if ( (exp == 0x7FFF) && sig64 ) {
78#if (ui32_fromNaN == ui32_fromPosOverflow)
79 sign = 0;
80#elif (ui32_fromNaN == ui32_fromNegOverflow)
81 sign = 1;
82#else
84 return ui32_fromNaN;
85#endif
86 }
87#endif
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
91 shiftDist = 0x4023 - exp;
92 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
93 return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
94
95}
Here is the call graph for this function:

◆ f128M_to_ui32_r_minMag()

uint_fast32_t f128M_to_ui32_r_minMag ( const float128_t * aPtr,
bool exact )

Definition at line 55 of file f128M_to_ui32_r_minMag.c.

56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 int32_t exp;
60 uint64_t sig64;
61 int32_t shiftDist;
62 bool sign;
63 uint32_t z;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 aWPtr = (const uint32_t *) aPtr;
68 uiA96 = aWPtr[indexWordHi( 4 )];
69 exp = expF128UI96( uiA96 );
70 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
71 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 shiftDist = 0x402F - exp;
75 if ( 49 <= shiftDist ) {
76 if ( exact && (exp | sig64) ) {
78 }
79 return 0;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 sign = signF128UI96( uiA96 );
84 if ( sign || (shiftDist < 17) ) {
86 return
87 (exp == 0x7FFF) && sig64 ? ui32_fromNaN
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 sig64 |= UINT64_C( 0x0001000000000000 );
93 z = sig64>>shiftDist;
94 if ( exact && ((uint64_t) z<<shiftDist != sig64) ) {
96 }
97 return z;
98
99}
Here is the call graph for this function:

◆ f128M_to_ui64()

uint_fast64_t f128M_to_ui64 ( const float128_t * aPtr,
uint_fast8_t roundingMode,
bool exact )

Definition at line 57 of file f128M_to_ui64.c.

58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint32_t sig96;
64 int32_t shiftDist;
65 uint32_t sig[4];
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 sig96 = fracF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 shiftDist = 0x404F - exp;
77 if ( shiftDist < 17 ) {
79 return
80 (exp == 0x7FFF)
81 && (sig96
82 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
83 | aWPtr[indexWord( 4, 0 )]))
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( exp ) sig96 |= 0x00010000;
90 sig[indexWord( 4, 3 )] = sig96;
91 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
92 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
93 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
94 softfloat_shiftRightJam128M( sig, shiftDist, sig );
95 return
97 sign, sig + indexMultiwordLo( 4, 3 ), roundingMode, exact );
98
99}
uint_fast64_t softfloat_roundMToUI64(bool, uint32_t *, uint_fast8_t, bool)
Here is the call graph for this function:

◆ f128M_to_ui64_r_minMag()

uint_fast64_t f128M_to_ui64_r_minMag ( const float128_t * aPtr,
bool exact )

Definition at line 55 of file f128M_to_ui64_r_minMag.c.

56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint32_t sig96;
62 int32_t shiftDist;
63 uint32_t sig[4];
64 uint64_t z;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig96 = fracF128UI96( uiA96 );
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 shiftDist = 0x403E - exp;
76 if ( shiftDist < 0 ) goto invalid;
77 if ( exact ) {
78 if ( exp ) sig96 |= 0x00010000;
79 sig[indexWord( 4, 3 )] = sig96;
80 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
81 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
82 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
83 softfloat_shiftRightJam128M( sig, shiftDist + 17, sig );
84 z = (uint64_t) sig[indexWord( 4, 2 )]<<32 | sig[indexWord( 4, 1 )];
85 if ( sign && z ) goto invalid;
86 if ( sig[indexWordLo( 4 )] ) {
88 }
89 } else {
90 if ( 64 <= shiftDist ) return 0;
91 if ( sign ) goto invalid;
92 z = UINT64_C( 0x8000000000000000 )
93 | (uint64_t) sig96<<47
94 | (uint64_t) aWPtr[indexWord( 4, 2 )]<<15
95 | aWPtr[indexWord( 4, 1 )]>>17;
96 z >>= shiftDist;
97 }
98 return z;
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 invalid:
103 return
104 (exp == 0x7FFF)
105 && (sig96
106 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
107 | aWPtr[indexWord( 4, 0 )]))
110
111}
Here is the call graph for this function:

◆ f16_add()

float16_t f16_add ( float16_t a,
float16_t b )

Definition at line 43 of file f16_add.c.

44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF16UI( uiA ^ uiB ) ) {
59 return softfloat_subMagsF16( uiA, uiB );
60 } else {
61 return softfloat_addMagsF16( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
#define signF16UI(a)
Definition internals.h:83
float16_t softfloat_subMagsF16(uint_fast16_t, uint_fast16_t)
float16_t softfloat_addMagsF16(uint_fast16_t, uint_fast16_t)
Here is the call graph for this function:

◆ f16_div()

float16_t f16_div ( float16_t a,
float16_t b )

Definition at line 47 of file f16_div.c.

48{
49 union ui16_f16 uA;
50 uint_fast16_t uiA;
51 bool signA;
52 int_fast8_t expA;
53 uint_fast16_t sigA;
54 union ui16_f16 uB;
55 uint_fast16_t uiB;
56 bool signB;
57 int_fast8_t expB;
58 uint_fast16_t sigB;
59 bool signZ;
60 struct exp8_sig16 normExpSig;
61 int_fast8_t expZ;
62#ifdef SOFTFLOAT_FAST_DIV32TO16
63 uint_fast32_t sig32A;
64 uint_fast16_t sigZ;
65#else
66 int index;
67 uint16_t r0;
68 uint_fast16_t sigZ, rem;
69#endif
70 uint_fast16_t uiZ;
71 union ui16_f16 uZ;
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 uA.f = a;
76 uiA = uA.ui;
77 signA = signF16UI( uiA );
78 expA = expF16UI( uiA );
79 sigA = fracF16UI( uiA );
80 uB.f = b;
81 uiB = uB.ui;
82 signB = signF16UI( uiB );
83 expB = expF16UI( uiB );
84 sigB = fracF16UI( uiB );
85 signZ = signA ^ signB;
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( expA == 0x1F ) {
89 if ( sigA ) goto propagateNaN;
90 if ( expB == 0x1F ) {
91 if ( sigB ) goto propagateNaN;
92 goto invalid;
93 }
94 goto infinity;
95 }
96 if ( expB == 0x1F ) {
97 if ( sigB ) goto propagateNaN;
98 goto zero;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 if ( ! expB ) {
103 if ( ! sigB ) {
104 if ( ! (expA | sigA) ) goto invalid;
106 goto infinity;
107 }
108 normExpSig = softfloat_normSubnormalF16Sig( sigB );
109 expB = normExpSig.exp;
110 sigB = normExpSig.sig;
111 }
112 if ( ! expA ) {
113 if ( ! sigA ) goto zero;
114 normExpSig = softfloat_normSubnormalF16Sig( sigA );
115 expA = normExpSig.exp;
116 sigA = normExpSig.sig;
117 }
118 /*------------------------------------------------------------------------
119 *------------------------------------------------------------------------*/
120 expZ = expA - expB + 0xE;
121 sigA |= 0x0400;
122 sigB |= 0x0400;
123#ifdef SOFTFLOAT_FAST_DIV32TO16
124 if ( sigA < sigB ) {
125 --expZ;
126 sig32A = (uint_fast32_t) sigA<<15;
127 } else {
128 sig32A = (uint_fast32_t) sigA<<14;
129 }
130 sigZ = sig32A / sigB;
131 if ( ! (sigZ & 7) ) sigZ |= ((uint_fast32_t) sigB * sigZ != sig32A);
132#else
133 if ( sigA < sigB ) {
134 --expZ;
135 sigA <<= 5;
136 } else {
137 sigA <<= 4;
138 }
139 index = sigB>>6 & 0xF;
142 * (sigB & 0x3F))
143 >>10);
144 sigZ = ((uint_fast32_t) sigA * r0)>>16;
145 rem = (sigA<<10) - sigZ * sigB;
146 sigZ += (rem * (uint_fast32_t) r0)>>26;
147 /*------------------------------------------------------------------------
148 *------------------------------------------------------------------------*/
149 ++sigZ;
150 if ( ! (sigZ & 7) ) {
151 sigZ &= ~1;
152 rem = (sigA<<10) - sigZ * sigB;
153 if ( rem & 0x8000 ) {
154 sigZ -= 2;
155 } else {
156 if ( rem ) sigZ |= 1;
157 }
158 }
159#endif
160 return softfloat_roundPackToF16( signZ, expZ, sigZ );
161 /*------------------------------------------------------------------------
162 *------------------------------------------------------------------------*/
163 propagateNaN:
164 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
165 goto uiZ;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
170 uiZ = defaultNaNF16UI;
171 goto uiZ;
172 /*------------------------------------------------------------------------
173 *------------------------------------------------------------------------*/
174 infinity:
175 uiZ = packToF16UI( signZ, 0x1F, 0 );
176 goto uiZ;
177 /*------------------------------------------------------------------------
178 *------------------------------------------------------------------------*/
179 zero:
180 uiZ = packToF16UI( signZ, 0, 0 );
181 uiZ:
182 uZ.ui = uiZ;
183 return uZ.f;
184
185}
uint_fast16_t softfloat_propagateNaNF16UI(uint_fast16_t uiA, uint_fast16_t uiB)
#define defaultNaNF16UI
Definition specialize.h:88
const uint16_t softfloat_approxRecip_1k0s[]
const uint16_t softfloat_approxRecip_1k1s[]
#define expF16UI(a)
Definition internals.h:84
#define fracF16UI(a)
Definition internals.h:85
struct exp8_sig16 softfloat_normSubnormalF16Sig(uint_fast16_t)
Here is the call graph for this function:

◆ f16_eq()

bool f16_eq ( float16_t a,
float16_t b )

Definition at line 44 of file f16_eq.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 union ui16_f16 uB;
49 uint_fast16_t uiB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56 if (
58 ) {
60 }
61 return false;
62 }
63 return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
64
65}
#define softfloat_isSigNaNF16UI(uiA)
Definition specialize.h:95
#define isNaNF16UI(a)
Definition internals.h:88
Here is the call graph for this function:

◆ f16_eq_signaling()

bool f16_eq_signaling ( float16_t a,
float16_t b )

Definition at line 43 of file f16_eq_signaling.c.

44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49
50 uA.f = a;
51 uiA = uA.ui;
52 uB.f = b;
53 uiB = uB.ui;
54 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56 return false;
57 }
58 return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
59
60}
Here is the call graph for this function:

◆ f16_isSignalingNaN()

bool f16_isSignalingNaN ( float16_t a)

Definition at line 43 of file f16_isSignalingNaN.c.

44{
45 union ui16_f16 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF16UI( uA.ui );
49
50}

◆ f16_le()

bool f16_le ( float16_t a,
float16_t b )

Definition at line 43 of file f16_le.c.

44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
57 return false;
58 }
59 signA = signF16UI( uiA );
60 signB = signF16UI( uiB );
61 return
62 (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
63 : (uiA == uiB) || (signA ^ (uiA < uiB));
64
65}
Here is the call graph for this function:

◆ f16_le_quiet()

bool f16_le_quiet ( float16_t a,
float16_t b )

Definition at line 44 of file f16_le_quiet.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 union ui16_f16 uB;
49 uint_fast16_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
57 if (
59 ) {
61 }
62 return false;
63 }
64 signA = signF16UI( uiA );
65 signB = signF16UI( uiB );
66 return
67 (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
68 : (uiA == uiB) || (signA ^ (uiA < uiB));
69
70}
Here is the call graph for this function:

◆ f16_lt()

bool f16_lt ( float16_t a,
float16_t b )

Definition at line 43 of file f16_lt.c.

44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
57 return false;
58 }
59 signA = signF16UI( uiA );
60 signB = signF16UI( uiB );
61 return
62 (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
63 : (uiA != uiB) && (signA ^ (uiA < uiB));
64
65}
Here is the call graph for this function:

◆ f16_lt_quiet()

bool f16_lt_quiet ( float16_t a,
float16_t b )

Definition at line 44 of file f16_lt_quiet.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 union ui16_f16 uB;
49 uint_fast16_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
57 if (
59 ) {
61 }
62 return false;
63 }
64 signA = signF16UI( uiA );
65 signB = signF16UI( uiB );
66 return
67 (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
68 : (uiA != uiB) && (signA ^ (uiA < uiB));
69
70}
Here is the call graph for this function:

◆ f16_mul()

float16_t f16_mul ( float16_t a,
float16_t b )

Definition at line 44 of file f16_mul.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool signA;
49 int_fast8_t expA;
50 uint_fast16_t sigA;
51 union ui16_f16 uB;
52 uint_fast16_t uiB;
53 bool signB;
54 int_fast8_t expB;
55 uint_fast16_t sigB;
56 bool signZ;
57 uint_fast16_t magBits;
58 struct exp8_sig16 normExpSig;
59 int_fast8_t expZ;
60 uint_fast32_t sig32Z;
61 uint_fast16_t sigZ, uiZ;
62 union ui16_f16 uZ;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 uA.f = a;
67 uiA = uA.ui;
68 signA = signF16UI( uiA );
69 expA = expF16UI( uiA );
70 sigA = fracF16UI( uiA );
71 uB.f = b;
72 uiB = uB.ui;
73 signB = signF16UI( uiB );
74 expB = expF16UI( uiB );
75 sigB = fracF16UI( uiB );
76 signZ = signA ^ signB;
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( expA == 0x1F ) {
80 if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
81 magBits = expB | sigB;
82 goto infArg;
83 }
84 if ( expB == 0x1F ) {
85 if ( sigB ) goto propagateNaN;
86 magBits = expA | sigA;
87 goto infArg;
88 }
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( ! expA ) {
92 if ( ! sigA ) goto zero;
93 normExpSig = softfloat_normSubnormalF16Sig( sigA );
94 expA = normExpSig.exp;
95 sigA = normExpSig.sig;
96 }
97 if ( ! expB ) {
98 if ( ! sigB ) goto zero;
99 normExpSig = softfloat_normSubnormalF16Sig( sigB );
100 expB = normExpSig.exp;
101 sigB = normExpSig.sig;
102 }
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 expZ = expA + expB - 0xF;
106 sigA = (sigA | 0x0400)<<4;
107 sigB = (sigB | 0x0400)<<5;
108 sig32Z = (uint_fast32_t) sigA * sigB;
109 sigZ = sig32Z>>16;
110 if ( sig32Z & 0xFFFF ) sigZ |= 1;
111 if ( sigZ < 0x4000 ) {
112 --expZ;
113 sigZ <<= 1;
114 }
115 return softfloat_roundPackToF16( signZ, expZ, sigZ );
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 propagateNaN:
119 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
120 goto uiZ;
121 /*------------------------------------------------------------------------
122 *------------------------------------------------------------------------*/
123 infArg:
124 if ( ! magBits ) {
126 uiZ = defaultNaNF16UI;
127 } else {
128 uiZ = packToF16UI( signZ, 0x1F, 0 );
129 }
130 goto uiZ;
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 zero:
134 uiZ = packToF16UI( signZ, 0, 0 );
135 uiZ:
136 uZ.ui = uiZ;
137 return uZ.f;
138
139}
Here is the call graph for this function:

◆ f16_mulAdd()

float16_t f16_mulAdd ( float16_t a,
float16_t b,
float16_t c )

Definition at line 42 of file f16_mulAdd.c.

43{
44 union ui16_f16 uA;
45 uint_fast16_t uiA;
46 union ui16_f16 uB;
47 uint_fast16_t uiB;
48 union ui16_f16 uC;
49 uint_fast16_t uiC;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 uC.f = c;
56 uiC = uC.ui;
57 return softfloat_mulAddF16( uiA, uiB, uiC, 0 );
58
59}
float16_t softfloat_mulAddF16(uint_fast16_t, uint_fast16_t, uint_fast16_t, uint_fast8_t)
Definition s_mulAddF16.c:45
Here is the call graph for this function:

◆ f16_rem()

float16_t f16_rem ( float16_t a,
float16_t b )

Definition at line 44 of file f16_rem.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool signA;
49 int_fast8_t expA;
50 uint_fast16_t sigA;
51 union ui16_f16 uB;
52 uint_fast16_t uiB;
53 int_fast8_t expB;
54 uint_fast16_t sigB;
55 struct exp8_sig16 normExpSig;
56 uint16_t rem;
57 int_fast8_t expDiff;
59 uint32_t recip32, q32;
60 uint16_t altRem, meanRem;
61 bool signRem;
62 uint_fast16_t uiZ;
63 union ui16_f16 uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 uA.f = a;
68 uiA = uA.ui;
69 signA = signF16UI( uiA );
70 expA = expF16UI( uiA );
71 sigA = fracF16UI( uiA );
72 uB.f = b;
73 uiB = uB.ui;
74 expB = expF16UI( uiB );
75 sigB = fracF16UI( uiB );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( expA == 0x1F ) {
79 if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
80 goto invalid;
81 }
82 if ( expB == 0x1F ) {
83 if ( sigB ) goto propagateNaN;
84 return a;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( ! expB ) {
89 if ( ! sigB ) goto invalid;
90 normExpSig = softfloat_normSubnormalF16Sig( sigB );
91 expB = normExpSig.exp;
92 sigB = normExpSig.sig;
93 }
94 if ( ! expA ) {
95 if ( ! sigA ) return a;
96 normExpSig = softfloat_normSubnormalF16Sig( sigA );
97 expA = normExpSig.exp;
98 sigA = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 rem = sigA | 0x0400;
103 sigB |= 0x0400;
104 expDiff = expA - expB;
105 if ( expDiff < 1 ) {
106 if ( expDiff < -1 ) return a;
107 sigB <<= 3;
108 if ( expDiff ) {
109 rem <<= 2;
110 q = 0;
111 } else {
112 rem <<= 3;
113 q = (sigB <= rem);
114 if ( q ) rem -= sigB;
115 }
116 } else {
117 recip32 = softfloat_approxRecip32_1( (uint_fast32_t) sigB<<21 );
118 /*--------------------------------------------------------------------
119 | Changing the shift of `rem' here requires also changing the initial
120 | subtraction from `expDiff'.
121 *--------------------------------------------------------------------*/
122 rem <<= 4;
123 expDiff -= 31;
124 /*--------------------------------------------------------------------
125 | The scale of `sigB' affects how many bits are obtained during each
126 | cycle of the loop. Currently this is 29 bits per loop iteration,
127 | which is believed to be the maximum possible.
128 *--------------------------------------------------------------------*/
129 sigB <<= 3;
130 for (;;) {
131 q32 = (rem * (uint_fast64_t) recip32)>>16;
132 if ( expDiff < 0 ) break;
133 rem = -((uint_fast16_t) q32 * sigB);
134 expDiff -= 29;
135 }
136 /*--------------------------------------------------------------------
137 | (`expDiff' cannot be less than -30 here.)
138 *--------------------------------------------------------------------*/
139 q32 >>= ~expDiff & 31;
140 q = q32;
141 rem = (rem<<(expDiff + 30)) - q * sigB;
142 }
143 /*------------------------------------------------------------------------
144 *------------------------------------------------------------------------*/
145 do {
146 altRem = rem;
147 ++q;
148 rem -= sigB;
149 } while ( ! (rem & 0x8000) );
150 meanRem = rem + altRem;
151 if ( (meanRem & 0x8000) || (! meanRem && (q & 1)) ) rem = altRem;
152 signRem = signA;
153 if ( 0x8000 <= rem ) {
154 signRem = ! signRem;
155 rem = -rem;
156 }
157 return softfloat_normRoundPackToF16( signRem, expB, rem );
158 /*------------------------------------------------------------------------
159 *------------------------------------------------------------------------*/
160 propagateNaN:
161 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
162 goto uiZ;
163 invalid:
165 uiZ = defaultNaNF16UI;
166 uiZ:
167 uZ.ui = uiZ;
168 return uZ.f;
169
170}
float16_t softfloat_normRoundPackToF16(bool, int_fast16_t, uint_fast16_t)
Here is the call graph for this function:

◆ f16_roundToInt()

float16_t f16_roundToInt ( float16_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f16_roundToInt.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t uiZ, lastBitMask, roundBitsMask;
50 union ui16_f16 uZ;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uA.f = a;
55 uiA = uA.ui;
56 exp = expF16UI( uiA );
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 if ( exp <= 0xE ) {
60 if ( !(uint16_t) (uiA<<1) ) return a;
62 uiZ = uiA & packToF16UI( 1, 0, 0 );
63 switch ( roundingMode ) {
65 if ( !fracF16UI( uiA ) ) break;
67 if ( exp == 0xE ) uiZ |= packToF16UI( 0, 0xF, 0 );
68 break;
70 if ( uiZ ) uiZ = packToF16UI( 1, 0xF, 0 );
71 break;
73 if ( !uiZ ) uiZ = packToF16UI( 0, 0xF, 0 );
74 break;
75#ifdef SOFTFLOAT_ROUND_ODD
77 uiZ |= packToF16UI( 0, 0xF, 0 );
78 break;
79#endif
80 }
81 goto uiZ;
82 }
83 /*------------------------------------------------------------------------
84 *------------------------------------------------------------------------*/
85 if ( 0x19 <= exp ) {
86 if ( (exp == 0x1F) && fracF16UI( uiA ) ) {
87 uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
88 goto uiZ;
89 }
90 return a;
91 }
92 /*------------------------------------------------------------------------
93 *------------------------------------------------------------------------*/
94 uiZ = uiA;
95 lastBitMask = (uint_fast16_t) 1<<(0x19 - exp);
96 roundBitsMask = lastBitMask - 1;
97 if ( roundingMode == softfloat_round_near_maxMag ) {
98 uiZ += lastBitMask>>1;
99 } else if ( roundingMode == softfloat_round_near_even ) {
100 uiZ += lastBitMask>>1;
101 if ( !(uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
102 } else if (
103 roundingMode
105 ) {
106 uiZ += roundBitsMask;
107 }
108 uiZ &= ~roundBitsMask;
109 if ( uiZ != uiA ) {
110#ifdef SOFTFLOAT_ROUND_ODD
111 if ( roundingMode == softfloat_round_odd ) uiZ |= lastBitMask;
112#endif
114 }
115 uiZ:
116 uZ.ui = uiZ;
117 return uZ.f;
118
119}
Here is the call graph for this function:

◆ f16_sqrt()

float16_t f16_sqrt ( float16_t a)

Definition at line 47 of file f16_sqrt.c.

48{
49 union ui16_f16 uA;
50 uint_fast16_t uiA;
51 bool signA;
52 int_fast8_t expA;
53 uint_fast16_t sigA, uiZ;
54 struct exp8_sig16 normExpSig;
55 int_fast8_t expZ;
56 int index;
58 uint_fast32_t ESqrR0;
60 uint_fast16_t recipSqrt16, sigZ, shiftedSigZ;
61 uint16_t negRem;
62 union ui16_f16 uZ;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 uA.f = a;
67 uiA = uA.ui;
68 signA = signF16UI( uiA );
69 expA = expF16UI( uiA );
70 sigA = fracF16UI( uiA );
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 if ( expA == 0x1F ) {
74 if ( sigA ) {
75 uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
76 goto uiZ;
77 }
78 if ( ! signA ) return a;
79 goto invalid;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 if ( signA ) {
84 if ( ! (expA | sigA) ) return a;
85 goto invalid;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( ! expA ) {
90 if ( ! sigA ) return a;
91 normExpSig = softfloat_normSubnormalF16Sig( sigA );
92 expA = normExpSig.exp;
93 sigA = normExpSig.sig;
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 expZ = ((expA - 0xF)>>1) + 0xE;
98 expA &= 1;
99 sigA |= 0x0400;
100 index = (sigA>>6 & 0xE) + expA;
103 * (sigA & 0x7F))
104 >>11);
105 ESqrR0 = ((uint_fast32_t) r0 * r0)>>1;
106 if ( expA ) ESqrR0 >>= 1;
107 sigma0 = ~(uint_fast16_t) ((ESqrR0 * sigA)>>16);
108 recipSqrt16 = r0 + (((uint_fast32_t) r0 * sigma0)>>25);
109 if ( ! (recipSqrt16 & 0x8000) ) recipSqrt16 = 0x8000;
110 sigZ = ((uint_fast32_t) (sigA<<5) * recipSqrt16)>>16;
111 if ( expA ) sigZ >>= 1;
112 /*------------------------------------------------------------------------
113 *------------------------------------------------------------------------*/
114 ++sigZ;
115 if ( ! (sigZ & 7) ) {
116 shiftedSigZ = sigZ>>1;
117 negRem = shiftedSigZ * shiftedSigZ;
118 sigZ &= ~1;
119 if ( negRem & 0x8000 ) {
120 sigZ |= 1;
121 } else {
122 if ( negRem ) --sigZ;
123 }
124 }
125 return softfloat_roundPackToF16( 0, expZ, sigZ );
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 invalid:
130 uiZ = defaultNaNF16UI;
131 uiZ:
132 uZ.ui = uiZ;
133 return uZ.f;
134
135}
#define sigma0(x)
Definition hash_impl.h:21
const uint16_t softfloat_approxRecipSqrt_1k0s[]
const uint16_t softfloat_approxRecipSqrt_1k1s[]
Here is the call graph for this function:

◆ f16_sub()

float16_t f16_sub ( float16_t a,
float16_t b )

Definition at line 43 of file f16_sub.c.

44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF16UI( uiA ^ uiB ) ) {
59 return softfloat_addMagsF16( uiA, uiB );
60 } else {
61 return softfloat_subMagsF16( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
Here is the call graph for this function:

◆ f16_to_f128()

float128_t f16_to_f128 ( float16_t a)

Definition at line 44 of file f16_to_f128.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 struct exp8_sig16 normExpSig;
54 union ui128_f128 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF16UI( uiA );
61 exp = expF16UI( uiA );
62 frac = fracF16UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x1F ) {
66 if ( frac ) {
69 } else {
70 uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
71 uiZ.v0 = 0;
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( ! exp ) {
78 if ( ! frac ) {
79 uiZ.v64 = packToF128UI64( sign, 0, 0 );
80 uiZ.v0 = 0;
81 goto uiZ;
82 }
83 normExpSig = softfloat_normSubnormalF16Sig( frac );
84 exp = normExpSig.exp - 1;
85 frac = normExpSig.sig;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 uiZ.v64 = packToF128UI64( sign, exp + 0x3FF0, (uint_fast64_t) frac<<38 );
90 uiZ.v0 = 0;
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
#define softfloat_commonNaNToF128UI
#define softfloat_f16UIToCommonNaN(uiA, zPtr)
Definition specialize.h:96
Here is the call graph for this function:

◆ f16_to_f128M()

void f16_to_f128M ( float16_t a,
float128_t * zPtr )

Definition at line 55 of file f16_to_f128M.c.

56{
57 uint32_t *zWPtr;
58 union ui16_f16 uA;
59 uint16_t uiA;
60 bool sign;
61 int_fast8_t exp;
62 uint16_t frac;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65 struct exp8_sig16 normExpSig;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 zWPtr = (uint32_t *) zPtr;
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uA.f = a;
73 uiA = uA.ui;
74 sign = signF16UI( uiA );
75 exp = expF16UI( uiA );
76 frac = fracF16UI( uiA );
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( exp == 0x1F ) {
80 if ( frac ) {
83 return;
84 }
85 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! exp ) {
91 if ( ! frac ) {
92 uiZ96 = packToF128UI96( sign, 0, 0 );
93 goto uiZ;
94 }
95 normExpSig = softfloat_normSubnormalF16Sig( frac );
96 exp = normExpSig.exp - 1;
97 frac = normExpSig.sig;
98 }
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 uiZ96 = packToF128UI96( sign, exp + 0x3FF0, (uint32_t) frac<<6 );
102 uiZ:
103 zWPtr[indexWord( 4, 3 )] = uiZ96;
104 zWPtr[indexWord( 4, 2 )] = 0;
105 zWPtr[indexWord( 4, 1 )] = 0;
106 zWPtr[indexWord( 4, 0 )] = 0;
107
108}
#define softfloat_commonNaNToF128M
int_fast8_t exp
Definition internals.h:90
Here is the call graph for this function:

◆ f16_to_f32()

float32_t f16_to_f32 ( float16_t a)

Definition at line 44 of file f16_to_f32.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 uint_fast32_t uiZ;
53 struct exp8_sig16 normExpSig;
54 union ui32_f32 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF16UI( uiA );
61 exp = expF16UI( uiA );
62 frac = fracF16UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x1F ) {
66 if ( frac ) {
69 } else {
70 uiZ = packToF32UI( sign, 0xFF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! exp ) {
77 if ( ! frac ) {
78 uiZ = packToF32UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 normExpSig = softfloat_normSubnormalF16Sig( frac );
82 exp = normExpSig.exp - 1;
83 frac = normExpSig.sig;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 uiZ = packToF32UI( sign, exp + 0x70, (uint_fast32_t) frac<<13 );
88 uiZ:
89 uZ.ui = uiZ;
90 return uZ.f;
91
92}
Here is the call graph for this function:

◆ f16_to_f64()

float64_t f16_to_f64 ( float16_t a)

Definition at line 44 of file f16_to_f64.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 uint_fast64_t uiZ;
53 struct exp8_sig16 normExpSig;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF16UI( uiA );
61 exp = expF16UI( uiA );
62 frac = fracF16UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x1F ) {
66 if ( frac ) {
69 } else {
70 uiZ = packToF64UI( sign, 0x7FF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! exp ) {
77 if ( ! frac ) {
78 uiZ = packToF64UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 normExpSig = softfloat_normSubnormalF16Sig( frac );
82 exp = normExpSig.exp - 1;
83 frac = normExpSig.sig;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 uiZ = packToF64UI( sign, exp + 0x3F0, (uint_fast64_t) frac<<42 );
88 uiZ:
89 uZ.ui = uiZ;
90 return uZ.f;
91
92}
Here is the call graph for this function:

◆ f16_to_i32()

int_fast32_t f16_to_i32 ( float16_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f16_to_i32.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 int_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
65 return
66 frac ? i32_fromNaN
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( 0 <= shiftDist ) {
76 sig32 <<= shiftDist;
77 return sign ? -sig32 : sig32;
78 }
79 shiftDist = exp - 0x0D;
80 if ( 0 < shiftDist ) sig32 <<= shiftDist;
81 }
82 return
84 sign, (uint_fast32_t) sig32, roundingMode, exact );
85
86}
Here is the call graph for this function:

◆ f16_to_i32_r_minMag()

int_fast32_t f16_to_i32_r_minMag ( float16_t a,
bool exact )

Definition at line 44 of file f16_to_i32_r_minMag.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 int_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( exp == 0x1F ) {
74 return
75 (exp == 0x1F) && frac ? i32_fromNaN
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
83 }
84 alignedSig >>= 10;
85 return sign ? -alignedSig : alignedSig;
86
87}
Here is the call graph for this function:

◆ f16_to_i64()

int_fast64_t f16_to_i64 ( float16_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f16_to_i64.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 int_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
65 return
66 frac ? i64_fromNaN
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( 0 <= shiftDist ) {
76 sig32 <<= shiftDist;
77 return sign ? -sig32 : sig32;
78 }
79 shiftDist = exp - 0x0D;
80 if ( 0 < shiftDist ) sig32 <<= shiftDist;
81 }
82 return
84 sign, (uint_fast32_t) sig32, roundingMode, exact );
85
86}
Here is the call graph for this function:

◆ f16_to_i64_r_minMag()

int_fast64_t f16_to_i64_r_minMag ( float16_t a,
bool exact )

Definition at line 44 of file f16_to_i64_r_minMag.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 int_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( exp == 0x1F ) {
74 return
75 (exp == 0x1F) && frac ? i64_fromNaN
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
83 }
84 alignedSig >>= 10;
85 return sign ? -alignedSig : alignedSig;
86
87}
Here is the call graph for this function:

◆ f16_to_ui32()

uint_fast32_t f16_to_ui32 ( float16_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f16_to_ui32.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 uint_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
65 return
66 frac ? ui32_fromNaN
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( (0 <= shiftDist) && ! sign ) {
76 return sig32<<shiftDist;
77 }
78 shiftDist = exp - 0x0D;
79 if ( 0 < shiftDist ) sig32 <<= shiftDist;
80 }
81 return softfloat_roundToUI32( sign, sig32, roundingMode, exact );
82
83}
Here is the call graph for this function:

◆ f16_to_ui32_r_minMag()

uint_fast32_t f16_to_ui32_r_minMag ( float16_t a,
bool exact )

Definition at line 44 of file f16_to_ui32_r_minMag.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 uint_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( sign || (exp == 0x1F) ) {
74 return
75 (exp == 0x1F) && frac ? ui32_fromNaN
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (uint_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
83 }
84 return alignedSig>>10;
85
86}
Here is the call graph for this function:

◆ f16_to_ui64()

uint_fast64_t f16_to_ui64 ( float16_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f16_to_ui64.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 uint_fast32_t sig32;
52 int_fast8_t shiftDist;
53#ifndef SOFTFLOAT_FAST_INT64
54 uint32_t extSig[3];
55#endif
56
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 uA.f = a;
60 uiA = uA.ui;
61 sign = signF16UI( uiA );
62 exp = expF16UI( uiA );
63 frac = fracF16UI( uiA );
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( exp == 0x1F ) {
68 return
69 frac ? ui64_fromNaN
71 }
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 sig32 = frac;
75 if ( exp ) {
76 sig32 |= 0x0400;
77 shiftDist = exp - 0x19;
78 if ( (0 <= shiftDist) && ! sign ) {
79 return sig32<<shiftDist;
80 }
81 shiftDist = exp - 0x0D;
82 if ( 0 < shiftDist ) sig32 <<= shiftDist;
83 }
84#ifdef SOFTFLOAT_FAST_INT64
85 return
87 sign, sig32>>12, (uint_fast64_t) sig32<<52, roundingMode, exact );
88#else
89 extSig[indexWord( 3, 2 )] = 0;
90 extSig[indexWord( 3, 1 )] = sig32>>12;
91 extSig[indexWord( 3, 0 )] = sig32<<20;
92 return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
93#endif
94
95}
Here is the call graph for this function:

◆ f16_to_ui64_r_minMag()

uint_fast64_t f16_to_ui64_r_minMag ( float16_t a,
bool exact )

Definition at line 44 of file f16_to_ui64_r_minMag.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 uint_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( sign || (exp == 0x1F) ) {
74 return
75 (exp == 0x1F) && frac ? ui64_fromNaN
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (uint_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
83 }
84 return alignedSig>>10;
85
86}
Here is the call graph for this function:

◆ f32_add()

float32_t f32_add ( float32_t a,
float32_t b )

Definition at line 43 of file f32_add.c.

44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF32UI( uiA ^ uiB ) ) {
59 return softfloat_subMagsF32( uiA, uiB );
60 } else {
61 return softfloat_addMagsF32( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
float32_t softfloat_addMagsF32(uint_fast32_t, uint_fast32_t)
#define signF32UI(a)
Definition internals.h:104
float32_t softfloat_subMagsF32(uint_fast32_t, uint_fast32_t)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_div()

float32_t f32_div ( float32_t a,
float32_t b )

Definition at line 44 of file f32_div.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 union ui32_f32 uB;
52 uint_fast32_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast32_t sigB;
56 bool signZ;
57 struct exp16_sig32 normExpSig;
58 int_fast16_t expZ;
59#ifdef SOFTFLOAT_FAST_DIV64TO32
60 uint_fast64_t sig64A;
61 uint_fast32_t sigZ;
62#else
63 uint_fast32_t sigZ;
64 uint_fast64_t rem;
65#endif
66 uint_fast32_t uiZ;
67 union ui32_f32 uZ;
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uA.f = a;
72 uiA = uA.ui;
73 signA = signF32UI( uiA );
74 expA = expF32UI( uiA );
75 sigA = fracF32UI( uiA );
76 uB.f = b;
77 uiB = uB.ui;
78 signB = signF32UI( uiB );
79 expB = expF32UI( uiB );
80 sigB = fracF32UI( uiB );
81 signZ = signA ^ signB;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0xFF ) {
85 if ( sigA ) goto propagateNaN;
86 if ( expB == 0xFF ) {
87 if ( sigB ) goto propagateNaN;
88 goto invalid;
89 }
90 goto infinity;
91 }
92 if ( expB == 0xFF ) {
93 if ( sigB ) goto propagateNaN;
94 goto zero;
95 }
96 /*------------------------------------------------------------------------
97 *------------------------------------------------------------------------*/
98 if ( ! expB ) {
99 if ( ! sigB ) {
100 if ( ! (expA | sigA) ) goto invalid;
102 goto infinity;
103 }
104 normExpSig = softfloat_normSubnormalF32Sig( sigB );
105 expB = normExpSig.exp;
106 sigB = normExpSig.sig;
107 }
108 if ( ! expA ) {
109 if ( ! sigA ) goto zero;
110 normExpSig = softfloat_normSubnormalF32Sig( sigA );
111 expA = normExpSig.exp;
112 sigA = normExpSig.sig;
113 }
114 /*------------------------------------------------------------------------
115 *------------------------------------------------------------------------*/
116 expZ = expA - expB + 0x7E;
117 sigA |= 0x00800000;
118 sigB |= 0x00800000;
119#ifdef SOFTFLOAT_FAST_DIV64TO32
120 if ( sigA < sigB ) {
121 --expZ;
122 sig64A = (uint_fast64_t) sigA<<31;
123 } else {
124 sig64A = (uint_fast64_t) sigA<<30;
125 }
126 sigZ = sig64A / sigB;
127 if ( ! (sigZ & 0x3F) ) sigZ |= ((uint_fast64_t) sigB * sigZ != sig64A);
128#else
129 if ( sigA < sigB ) {
130 --expZ;
131 sigA <<= 8;
132 } else {
133 sigA <<= 7;
134 }
135 sigB <<= 8;
136 sigZ = ((uint_fast64_t) sigA * softfloat_approxRecip32_1( sigB ))>>32;
137 /*------------------------------------------------------------------------
138 *------------------------------------------------------------------------*/
139 sigZ += 2;
140 if ( (sigZ & 0x3F) < 2 ) {
141 sigZ &= ~3;
142#ifdef SOFTFLOAT_FAST_INT64
143 rem = ((uint_fast64_t) sigA<<31) - (uint_fast64_t) sigZ * sigB;
144#else
145 rem = ((uint_fast64_t) sigA<<32) - (uint_fast64_t) (sigZ<<1) * sigB;
146#endif
147 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
148 sigZ -= 4;
149 } else {
150 if ( rem ) sigZ |= 1;
151 }
152 }
153#endif
154 return softfloat_roundPackToF32( signZ, expZ, sigZ );
155 /*------------------------------------------------------------------------
156 *------------------------------------------------------------------------*/
157 propagateNaN:
158 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
159 goto uiZ;
160 /*------------------------------------------------------------------------
161 *------------------------------------------------------------------------*/
162 invalid:
164 uiZ = defaultNaNF32UI;
165 goto uiZ;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 infinity:
169 uiZ = packToF32UI( signZ, 0xFF, 0 );
170 goto uiZ;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 zero:
174 uiZ = packToF32UI( signZ, 0, 0 );
175 uiZ:
176 uZ.ui = uiZ;
177 return uZ.f;
178
179}
uint_fast32_t softfloat_propagateNaNF32UI(uint_fast32_t uiA, uint_fast32_t uiB)
#define defaultNaNF32UI
Definition specialize.h:123
#define expF32UI(a)
Definition internals.h:105
struct exp16_sig32 softfloat_normSubnormalF32Sig(uint_fast32_t)
#define fracF32UI(a)
Definition internals.h:106
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_eq()

bool f32_eq ( float32_t a,
float32_t b )

Definition at line 44 of file f32_eq.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 union ui32_f32 uB;
49 uint_fast32_t uiB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
56 if (
58 ) {
60 }
61 return false;
62 }
63 return (uiA == uiB) || ! (uint32_t) ((uiA | uiB)<<1);
64
65}
#define softfloat_isSigNaNF32UI(uiA)
Definition specialize.h:130
#define isNaNF32UI(a)
Definition internals.h:109
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_eq_signaling()

bool f32_eq_signaling ( float32_t a,
float32_t b )

Definition at line 43 of file f32_eq_signaling.c.

44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49
50 uA.f = a;
51 uiA = uA.ui;
52 uB.f = b;
53 uiB = uB.ui;
54 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
56 return false;
57 }
58 return (uiA == uiB) || ! (uint32_t) ((uiA | uiB)<<1);
59
60}
Here is the call graph for this function:

◆ f32_is_nan()

bool f32_is_nan ( const float32_t f)
inline

Definition at line 266 of file softfloat.hpp.

266 {
267 return ((f.v & 0x7FFFFFFF) > 0x7F800000);
268}

◆ f32_isSignalingNaN()

bool f32_isSignalingNaN ( float32_t a)

Definition at line 43 of file f32_isSignalingNaN.c.

44{
45 union ui32_f32 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF32UI( uA.ui );
49
50}

◆ f32_le()

bool f32_le ( float32_t a,
float32_t b )

Definition at line 43 of file f32_le.c.

44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
57 return false;
58 }
59 signA = signF32UI( uiA );
60 signB = signF32UI( uiB );
61 return
62 (signA != signB) ? signA || ! (uint32_t) ((uiA | uiB)<<1)
63 : (uiA == uiB) || (signA ^ (uiA < uiB));
64
65}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_le_quiet()

bool f32_le_quiet ( float32_t a,
float32_t b )

Definition at line 44 of file f32_le_quiet.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 union ui32_f32 uB;
49 uint_fast32_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
57 if (
59 ) {
61 }
62 return false;
63 }
64 signA = signF32UI( uiA );
65 signB = signF32UI( uiB );
66 return
67 (signA != signB) ? signA || ! (uint32_t) ((uiA | uiB)<<1)
68 : (uiA == uiB) || (signA ^ (uiA < uiB));
69
70}
Here is the call graph for this function:

◆ f32_lt()

bool f32_lt ( float32_t a,
float32_t b )

Definition at line 43 of file f32_lt.c.

44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
57 return false;
58 }
59 signA = signF32UI( uiA );
60 signB = signF32UI( uiB );
61 return
62 (signA != signB) ? signA && ((uint32_t) ((uiA | uiB)<<1) != 0)
63 : (uiA != uiB) && (signA ^ (uiA < uiB));
64
65}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_lt_quiet()

bool f32_lt_quiet ( float32_t a,
float32_t b )

Definition at line 44 of file f32_lt_quiet.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 union ui32_f32 uB;
49 uint_fast32_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
57 if (
59 ) {
61 }
62 return false;
63 }
64 signA = signF32UI( uiA );
65 signB = signF32UI( uiB );
66 return
67 (signA != signB) ? signA && ((uint32_t) ((uiA | uiB)<<1) != 0)
68 : (uiA != uiB) && (signA ^ (uiA < uiB));
69
70}
Here is the call graph for this function:

◆ f32_mul()

float32_t f32_mul ( float32_t a,
float32_t b )

Definition at line 44 of file f32_mul.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 union ui32_f32 uB;
52 uint_fast32_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast32_t sigB;
56 bool signZ;
57 uint_fast32_t magBits;
58 struct exp16_sig32 normExpSig;
59 int_fast16_t expZ;
60 uint_fast32_t sigZ, uiZ;
61 union ui32_f32 uZ;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 uA.f = a;
66 uiA = uA.ui;
67 signA = signF32UI( uiA );
68 expA = expF32UI( uiA );
69 sigA = fracF32UI( uiA );
70 uB.f = b;
71 uiB = uB.ui;
72 signB = signF32UI( uiB );
73 expB = expF32UI( uiB );
74 sigB = fracF32UI( uiB );
75 signZ = signA ^ signB;
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( expA == 0xFF ) {
79 if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
80 magBits = expB | sigB;
81 goto infArg;
82 }
83 if ( expB == 0xFF ) {
84 if ( sigB ) goto propagateNaN;
85 magBits = expA | sigA;
86 goto infArg;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! expA ) {
91 if ( ! sigA ) goto zero;
92 normExpSig = softfloat_normSubnormalF32Sig( sigA );
93 expA = normExpSig.exp;
94 sigA = normExpSig.sig;
95 }
96 if ( ! expB ) {
97 if ( ! sigB ) goto zero;
98 normExpSig = softfloat_normSubnormalF32Sig( sigB );
99 expB = normExpSig.exp;
100 sigB = normExpSig.sig;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 expZ = expA + expB - 0x7F;
105 sigA = (sigA | 0x00800000)<<7;
106 sigB = (sigB | 0x00800000)<<8;
107 sigZ = softfloat_shortShiftRightJam64( (uint_fast64_t) sigA * sigB, 32 );
108 if ( sigZ < 0x40000000 ) {
109 --expZ;
110 sigZ <<= 1;
111 }
112 return softfloat_roundPackToF32( signZ, expZ, sigZ );
113 /*------------------------------------------------------------------------
114 *------------------------------------------------------------------------*/
115 propagateNaN:
116 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
117 goto uiZ;
118 /*------------------------------------------------------------------------
119 *------------------------------------------------------------------------*/
120 infArg:
121 if ( ! magBits ) {
123 uiZ = defaultNaNF32UI;
124 } else {
125 uiZ = packToF32UI( signZ, 0xFF, 0 );
126 }
127 goto uiZ;
128 /*------------------------------------------------------------------------
129 *------------------------------------------------------------------------*/
130 zero:
131 uiZ = packToF32UI( signZ, 0, 0 );
132 uiZ:
133 uZ.ui = uiZ;
134 return uZ.f;
135
136}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_mulAdd()

float32_t f32_mulAdd ( float32_t a,
float32_t b,
float32_t c )

Definition at line 42 of file f32_mulAdd.c.

43{
44 union ui32_f32 uA;
45 uint_fast32_t uiA;
46 union ui32_f32 uB;
47 uint_fast32_t uiB;
48 union ui32_f32 uC;
49 uint_fast32_t uiC;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 uC.f = c;
56 uiC = uC.ui;
57 return softfloat_mulAddF32( uiA, uiB, uiC, 0 );
58
59}
float32_t softfloat_mulAddF32(uint_fast32_t, uint_fast32_t, uint_fast32_t, uint_fast8_t)
Definition s_mulAddF32.c:45
Here is the call graph for this function:

◆ f32_negative_infinity()

float32_t f32_negative_infinity ( )
inline

Definition at line 276 of file softfloat.hpp.

276 {
277 return {0xff800000ul};
278}

◆ f32_positive_infinity()

float32_t f32_positive_infinity ( )
inline

Definition at line 279 of file softfloat.hpp.

279 {
280 return {0x7f800000ul};
281}

◆ f32_rem()

float32_t f32_rem ( float32_t a,
float32_t b )

Definition at line 44 of file f32_rem.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 union ui32_f32 uB;
52 uint_fast32_t uiB;
53 int_fast16_t expB;
54 uint_fast32_t sigB;
55 struct exp16_sig32 normExpSig;
56 uint32_t rem;
57 int_fast16_t expDiff;
58 uint32_t q, recip32, altRem, meanRem;
59 bool signRem;
60 uint_fast32_t uiZ;
61 union ui32_f32 uZ;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 uA.f = a;
66 uiA = uA.ui;
67 signA = signF32UI( uiA );
68 expA = expF32UI( uiA );
69 sigA = fracF32UI( uiA );
70 uB.f = b;
71 uiB = uB.ui;
72 expB = expF32UI( uiB );
73 sigB = fracF32UI( uiB );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( expA == 0xFF ) {
77 if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
78 goto invalid;
79 }
80 if ( expB == 0xFF ) {
81 if ( sigB ) goto propagateNaN;
82 return a;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 if ( ! expB ) {
87 if ( ! sigB ) goto invalid;
88 normExpSig = softfloat_normSubnormalF32Sig( sigB );
89 expB = normExpSig.exp;
90 sigB = normExpSig.sig;
91 }
92 if ( ! expA ) {
93 if ( ! sigA ) return a;
94 normExpSig = softfloat_normSubnormalF32Sig( sigA );
95 expA = normExpSig.exp;
96 sigA = normExpSig.sig;
97 }
98 /*------------------------------------------------------------------------
99 *------------------------------------------------------------------------*/
100 rem = sigA | 0x00800000;
101 sigB |= 0x00800000;
102 expDiff = expA - expB;
103 if ( expDiff < 1 ) {
104 if ( expDiff < -1 ) return a;
105 sigB <<= 6;
106 if ( expDiff ) {
107 rem <<= 5;
108 q = 0;
109 } else {
110 rem <<= 6;
111 q = (sigB <= rem);
112 if ( q ) rem -= sigB;
113 }
114 } else {
115 recip32 = softfloat_approxRecip32_1( sigB<<8 );
116 /*--------------------------------------------------------------------
117 | Changing the shift of `rem' here requires also changing the initial
118 | subtraction from `expDiff'.
119 *--------------------------------------------------------------------*/
120 rem <<= 7;
121 expDiff -= 31;
122 /*--------------------------------------------------------------------
123 | The scale of `sigB' affects how many bits are obtained during each
124 | cycle of the loop. Currently this is 29 bits per loop iteration,
125 | which is believed to be the maximum possible.
126 *--------------------------------------------------------------------*/
127 sigB <<= 6;
128 for (;;) {
129 q = (rem * (uint_fast64_t) recip32)>>32;
130 if ( expDiff < 0 ) break;
131 rem = -(q * (uint32_t) sigB);
132 expDiff -= 29;
133 }
134 /*--------------------------------------------------------------------
135 | (`expDiff' cannot be less than -30 here.)
136 *--------------------------------------------------------------------*/
137 q >>= ~expDiff & 31;
138 rem = (rem<<(expDiff + 30)) - q * (uint32_t) sigB;
139 }
140 /*------------------------------------------------------------------------
141 *------------------------------------------------------------------------*/
142 do {
143 altRem = rem;
144 ++q;
145 rem -= sigB;
146 } while ( ! (rem & 0x80000000) );
147 meanRem = rem + altRem;
148 if ( (meanRem & 0x80000000) || (! meanRem && (q & 1)) ) rem = altRem;
149 signRem = signA;
150 if ( 0x80000000 <= rem ) {
151 signRem = ! signRem;
152 rem = -rem;
153 }
154 return softfloat_normRoundPackToF32( signRem, expB, rem );
155 /*------------------------------------------------------------------------
156 *------------------------------------------------------------------------*/
157 propagateNaN:
158 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
159 goto uiZ;
160 invalid:
162 uiZ = defaultNaNF32UI;
163 uiZ:
164 uZ.ui = uiZ;
165 return uZ.f;
166
167}
float32_t softfloat_normRoundPackToF32(bool, int_fast16_t, uint_fast32_t)
Here is the call graph for this function:

◆ f32_roundToInt()

float32_t f32_roundToInt ( float32_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f32_roundToInt.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t uiZ, lastBitMask, roundBitsMask;
50 union ui32_f32 uZ;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uA.f = a;
55 uiA = uA.ui;
56 exp = expF32UI( uiA );
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 if ( exp <= 0x7E ) {
60 if ( !(uint32_t) (uiA<<1) ) return a;
62 uiZ = uiA & packToF32UI( 1, 0, 0 );
63 switch ( roundingMode ) {
65 if ( !fracF32UI( uiA ) ) break;
67 if ( exp == 0x7E ) uiZ |= packToF32UI( 0, 0x7F, 0 );
68 break;
70 if ( uiZ ) uiZ = packToF32UI( 1, 0x7F, 0 );
71 break;
73 if ( !uiZ ) uiZ = packToF32UI( 0, 0x7F, 0 );
74 break;
75#ifdef SOFTFLOAT_ROUND_ODD
77 uiZ |= packToF32UI( 0, 0x7F, 0 );
78 break;
79#endif
80 }
81 goto uiZ;
82 }
83 /*------------------------------------------------------------------------
84 *------------------------------------------------------------------------*/
85 if ( 0x96 <= exp ) {
86 if ( (exp == 0xFF) && fracF32UI( uiA ) ) {
87 uiZ = softfloat_propagateNaNF32UI( uiA, 0 );
88 goto uiZ;
89 }
90 return a;
91 }
92 /*------------------------------------------------------------------------
93 *------------------------------------------------------------------------*/
94 uiZ = uiA;
95 lastBitMask = (uint_fast32_t) 1<<(0x96 - exp);
96 roundBitsMask = lastBitMask - 1;
97 if ( roundingMode == softfloat_round_near_maxMag ) {
98 uiZ += lastBitMask>>1;
99 } else if ( roundingMode == softfloat_round_near_even ) {
100 uiZ += lastBitMask>>1;
101 if ( !(uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
102 } else if (
103 roundingMode
105 ) {
106 uiZ += roundBitsMask;
107 }
108 uiZ &= ~roundBitsMask;
109 if ( uiZ != uiA ) {
110#ifdef SOFTFLOAT_ROUND_ODD
111 if ( roundingMode == softfloat_round_odd ) uiZ |= lastBitMask;
112#endif
114 }
115 uiZ:
116 uZ.ui = uiZ;
117 return uZ.f;
118
119}
Here is the call graph for this function:

◆ f32_sign_bit()

bool f32_sign_bit ( float32_t f)
inline

Definition at line 262 of file softfloat.hpp.

262{ return f.v >> 31; }

◆ f32_sqrt()

float32_t f32_sqrt ( float32_t a)

Definition at line 44 of file f32_sqrt.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA, uiZ;
51 struct exp16_sig32 normExpSig;
52 int_fast16_t expZ;
53 uint_fast32_t sigZ, shiftedSigZ;
54 uint32_t negRem;
55 union ui32_f32 uZ;
56
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 uA.f = a;
60 uiA = uA.ui;
61 signA = signF32UI( uiA );
62 expA = expF32UI( uiA );
63 sigA = fracF32UI( uiA );
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( expA == 0xFF ) {
67 if ( sigA ) {
68 uiZ = softfloat_propagateNaNF32UI( uiA, 0 );
69 goto uiZ;
70 }
71 if ( ! signA ) return a;
72 goto invalid;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( signA ) {
77 if ( ! (expA | sigA) ) return a;
78 goto invalid;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 if ( ! expA ) {
83 if ( ! sigA ) return a;
84 normExpSig = softfloat_normSubnormalF32Sig( sigA );
85 expA = normExpSig.exp;
86 sigA = normExpSig.sig;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 expZ = ((expA - 0x7F)>>1) + 0x7E;
91 expA &= 1;
92 sigA = (sigA | 0x00800000)<<8;
93 sigZ =
94 ((uint_fast64_t) sigA * softfloat_approxRecipSqrt32_1( expA, sigA ))
95 >>32;
96 if ( expA ) sigZ >>= 1;
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 sigZ += 2;
100 if ( (sigZ & 0x3F) < 2 ) {
101 shiftedSigZ = sigZ>>2;
102 negRem = shiftedSigZ * shiftedSigZ;
103 sigZ &= ~3;
104 if ( negRem & 0x80000000 ) {
105 sigZ |= 1;
106 } else {
107 if ( negRem ) --sigZ;
108 }
109 }
110 return softfloat_roundPackToF32( 0, expZ, sigZ );
111 /*------------------------------------------------------------------------
112 *------------------------------------------------------------------------*/
113 invalid:
115 uiZ = defaultNaNF32UI;
116 uiZ:
117 uZ.ui = uiZ;
118 return uZ.f;
119
120}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_sub()

float32_t f32_sub ( float32_t a,
float32_t b )

Definition at line 43 of file f32_sub.c.

44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF32UI( uiA ^ uiB ) ) {
59 return softfloat_addMagsF32( uiA, uiB );
60 } else {
61 return softfloat_subMagsF32( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_to_f128()

float128_t f32_to_f128 ( float32_t a)

Definition at line 44 of file f32_to_f128.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 struct exp16_sig32 normExpSig;
54 union ui128_f128 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF32UI( uiA );
61 exp = expF32UI( uiA );
62 frac = fracF32UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0xFF ) {
66 if ( frac ) {
69 } else {
70 uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
71 uiZ.v0 = 0;
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( ! exp ) {
78 if ( ! frac ) {
79 uiZ.v64 = packToF128UI64( sign, 0, 0 );
80 uiZ.v0 = 0;
81 goto uiZ;
82 }
83 normExpSig = softfloat_normSubnormalF32Sig( frac );
84 exp = normExpSig.exp - 1;
85 frac = normExpSig.sig;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 uiZ.v64 = packToF128UI64( sign, exp + 0x3F80, (uint_fast64_t) frac<<25 );
90 uiZ.v0 = 0;
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
#define softfloat_f32UIToCommonNaN(uiA, zPtr)
Definition specialize.h:131
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_to_f128M()

void f32_to_f128M ( float32_t a,
float128_t * zPtr )

Definition at line 55 of file f32_to_f128M.c.

56{
57 uint32_t *zWPtr;
58 union ui32_f32 uA;
59 uint32_t uiA;
60 bool sign;
61 int_fast16_t exp;
62 uint32_t frac, uiZ64;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65 struct exp16_sig32 normExpSig;
66 uint64_t frac64;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 zWPtr = (uint32_t *) zPtr;
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 uA.f = a;
74 uiA = uA.ui;
75 sign = signF32UI( uiA );
76 exp = expF32UI( uiA );
77 frac = fracF32UI( uiA );
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 uiZ64 = 0;
81 if ( exp == 0xFF ) {
82 if ( frac ) {
85 return;
86 }
87 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
88 goto uiZ;
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 if ( ! exp ) {
93 if ( ! frac ) {
94 uiZ96 = packToF128UI96( sign, 0, 0 );
95 goto uiZ;
96 }
97 normExpSig = softfloat_normSubnormalF32Sig( frac );
98 exp = normExpSig.exp - 1;
99 frac = normExpSig.sig;
100 }
101 /*------------------------------------------------------------------------
102 *------------------------------------------------------------------------*/
103 frac64 = (uint64_t) frac<<25;
104 uiZ96 = packToF128UI96( sign, exp + 0x3F80, frac64>>32 );
105 uiZ64 = frac64;
106 uiZ:
107 zWPtr[indexWord( 4, 3 )] = uiZ96;
108 zWPtr[indexWord( 4, 2 )] = uiZ64;
109 zWPtr[indexWord( 4, 1 )] = 0;
110 zWPtr[indexWord( 4, 0 )] = 0;
111
112}
int_fast16_t exp
Definition internals.h:111
Here is the call graph for this function:

◆ f32_to_f16()

float16_t f32_to_f16 ( float32_t a)

Definition at line 44 of file f32_to_f16.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 uint_fast16_t uiZ, frac16;
53 union ui16_f16 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 sign = signF32UI( uiA );
60 exp = expF32UI( uiA );
61 frac = fracF32UI( uiA );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( exp == 0xFF ) {
65 if ( frac ) {
68 } else {
69 uiZ = packToF16UI( sign, 0x1F, 0 );
70 }
71 goto uiZ;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 frac16 = frac>>9 | ((frac & 0x1FF) != 0);
76 if ( ! (exp | frac16) ) {
77 uiZ = packToF16UI( sign, 0, 0 );
78 goto uiZ;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 return softfloat_roundPackToF16( sign, exp - 0x71, frac16 | 0x4000 );
83 uiZ:
84 uZ.ui = uiZ;
85 return uZ.f;
86
87}
Here is the call graph for this function:

◆ f32_to_f64()

float64_t f32_to_f64 ( float32_t a)

Definition at line 44 of file f32_to_f64.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 uint_fast64_t uiZ;
53 struct exp16_sig32 normExpSig;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF32UI( uiA );
61 exp = expF32UI( uiA );
62 frac = fracF32UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0xFF ) {
66 if ( frac ) {
69 } else {
70 uiZ = packToF64UI( sign, 0x7FF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! exp ) {
77 if ( ! frac ) {
78 uiZ = packToF64UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 normExpSig = softfloat_normSubnormalF32Sig( frac );
82 exp = normExpSig.exp - 1;
83 frac = normExpSig.sig;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 uiZ = packToF64UI( sign, exp + 0x380, (uint_fast64_t) frac<<29 );
88 uiZ:
89 uZ.ui = uiZ;
90 return uZ.f;
91
92}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_to_i32()

int_fast32_t f32_to_i32 ( float32_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f32_to_i32.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 uint_fast64_t sig64;
52 int_fast16_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF32UI( uiA );
59 exp = expF32UI( uiA );
60 sig = fracF32UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
64 if ( (exp == 0xFF) && sig ) {
65#if (i32_fromNaN == i32_fromPosOverflow)
66 sign = 0;
67#elif (i32_fromNaN == i32_fromNegOverflow)
68 sign = 1;
69#else
71 return i32_fromNaN;
72#endif
73 }
74#endif
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78 sig64 = (uint_fast64_t) sig<<32;
79 shiftDist = 0xAA - exp;
80 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
81 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
82
83}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_to_i32_r_minMag()

int_fast32_t f32_to_i32_r_minMag ( float32_t a,
bool exact )

Definition at line 44 of file f32_to_i32_r_minMag.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF32UI( uiA );
59 sig = fracF32UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x9E - exp;
63 if ( 32 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF32UI( uiA );
72 if ( shiftDist <= 0 ) {
73 if ( uiA == packToF32UI( 1, 0x9E, 0 ) ) return -0x7FFFFFFF - 1;
75 return
76 (exp == 0xFF) && sig ? i32_fromNaN
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 sig = (sig | 0x00800000)<<8;
82 absZ = sig>>shiftDist;
83 if ( exact && ((uint_fast32_t) absZ<<shiftDist != sig) ) {
85 }
86 return sign ? -absZ : absZ;
87
88}
Here is the call graph for this function:

◆ f32_to_i64()

int_fast64_t f32_to_i64 ( float32_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f32_to_i64.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 uint_fast64_t sig64, extra;
54 struct uint64_extra sig64Extra;
55#else
56 uint32_t extSig[3];
57#endif
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA = uA.ui;
63 sign = signF32UI( uiA );
64 exp = expF32UI( uiA );
65 sig = fracF32UI( uiA );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 shiftDist = 0xBE - exp;
69 if ( shiftDist < 0 ) {
71 return
72 (exp == 0xFF) && sig ? i64_fromNaN
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78#ifdef SOFTFLOAT_FAST_INT64
79 sig64 = (uint_fast64_t) sig<<40;
80 extra = 0;
81 if ( shiftDist ) {
82 sig64Extra = softfloat_shiftRightJam64Extra( sig64, 0, shiftDist );
83 sig64 = sig64Extra.v;
84 extra = sig64Extra.extra;
85 }
86 return softfloat_roundToI64( sign, sig64, extra, roundingMode, exact );
87#else
88 extSig[indexWord( 3, 2 )] = sig<<8;
89 extSig[indexWord( 3, 1 )] = 0;
90 extSig[indexWord( 3, 0 )] = 0;
91 if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
92 return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
93#endif
94
95}
#define softfloat_shiftRightJam96M(aPtr, dist, zPtr)
Definition primitives.h:873
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_to_i64_r_minMag()

int_fast64_t f32_to_i64_r_minMag ( float32_t a,
bool exact )

Definition at line 44 of file f32_to_i64_r_minMag.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast64_t sig64;
53 int_fast64_t absZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 exp = expF32UI( uiA );
60 sig = fracF32UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0xBE - exp;
64 if ( 64 <= shiftDist ) {
65 if ( exact && (exp | sig) ) {
67 }
68 return 0;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 sign = signF32UI( uiA );
73 if ( shiftDist <= 0 ) {
74 if ( uiA == packToF32UI( 1, 0xBE, 0 ) ) {
75 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
76 }
78 return
79 (exp == 0xFF) && sig ? i64_fromNaN
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 sig |= 0x00800000;
85 sig64 = (uint_fast64_t) sig<<40;
86 absZ = sig64>>shiftDist;
87 shiftDist = 40 - shiftDist;
88 if ( exact && (shiftDist < 0) && (uint32_t) (sig<<(shiftDist & 31)) ) {
90 }
91 return sign ? -absZ : absZ;
92
93}
Here is the call graph for this function:

◆ f32_to_ui32()

uint_fast32_t f32_to_ui32 ( float32_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f32_to_ui32.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 uint_fast64_t sig64;
52 int_fast16_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF32UI( uiA );
59 exp = expF32UI( uiA );
60 sig = fracF32UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
64 if ( (exp == 0xFF) && sig ) {
65#if (ui32_fromNaN == ui32_fromPosOverflow)
66 sign = 0;
67#elif (ui32_fromNaN == ui32_fromNegOverflow)
68 sign = 1;
69#else
71 return ui32_fromNaN;
72#endif
73 }
74#endif
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78 sig64 = (uint_fast64_t) sig<<32;
79 shiftDist = 0xAA - exp;
80 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
81 return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
82
83}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_to_ui32_r_minMag()

uint_fast32_t f32_to_ui32_r_minMag ( float32_t a,
bool exact )

Definition at line 44 of file f32_to_ui32_r_minMag.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF32UI( uiA );
59 sig = fracF32UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x9E - exp;
63 if ( 32 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF32UI( uiA );
72 if ( sign || (shiftDist < 0) ) {
74 return
75 (exp == 0xFF) && sig ? ui32_fromNaN
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 sig = (sig | 0x00800000)<<8;
81 z = sig>>shiftDist;
82 if ( exact && (z<<shiftDist != sig) ) {
84 }
85 return z;
86
87}
Here is the call graph for this function:

◆ f32_to_ui64()

uint_fast64_t f32_to_ui64 ( float32_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f32_to_ui64.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 uint_fast64_t sig64, extra;
54 struct uint64_extra sig64Extra;
55#else
56 uint32_t extSig[3];
57#endif
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA = uA.ui;
63 sign = signF32UI( uiA );
64 exp = expF32UI( uiA );
65 sig = fracF32UI( uiA );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 shiftDist = 0xBE - exp;
69 if ( shiftDist < 0 ) {
71 return
72 (exp == 0xFF) && sig ? ui64_fromNaN
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78#ifdef SOFTFLOAT_FAST_INT64
79 sig64 = (uint_fast64_t) sig<<40;
80 extra = 0;
81 if ( shiftDist ) {
82 sig64Extra = softfloat_shiftRightJam64Extra( sig64, 0, shiftDist );
83 sig64 = sig64Extra.v;
84 extra = sig64Extra.extra;
85 }
86 return softfloat_roundToUI64( sign, sig64, extra, roundingMode, exact );
87#else
88 extSig[indexWord( 3, 2 )] = sig<<8;
89 extSig[indexWord( 3, 1 )] = 0;
90 extSig[indexWord( 3, 0 )] = 0;
91 if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
92 return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
93#endif
94
95}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f32_to_ui64_r_minMag()

uint_fast64_t f32_to_ui64_r_minMag ( float32_t a,
bool exact )

Definition at line 44 of file f32_to_ui64_r_minMag.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast64_t sig64, z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF32UI( uiA );
59 sig = fracF32UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0xBE - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF32UI( uiA );
72 if ( sign || (shiftDist < 0) ) {
74 return
75 (exp == 0xFF) && sig ? ui64_fromNaN
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 sig |= 0x00800000;
81 sig64 = (uint_fast64_t) sig<<40;
82 z = sig64>>shiftDist;
83 shiftDist = 40 - shiftDist;
84 if ( exact && (shiftDist < 0) && (uint32_t) (sig<<(shiftDist & 31)) ) {
86 }
87 return z;
88
89}
Here is the call graph for this function:

◆ f64_add()

float64_t f64_add ( float64_t a,
float64_t b )

Definition at line 43 of file f64_add.c.

44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 bool signA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52 float64_t (*magsFuncPtr)( uint_fast64_t, uint_fast64_t, bool );
53#endif
54
55 uA.f = a;
56 uiA = uA.ui;
57 signA = signF64UI( uiA );
58 uB.f = b;
59 uiB = uB.ui;
60 signB = signF64UI( uiB );
61#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
62 if ( signA == signB ) {
63 return softfloat_addMagsF64( uiA, uiB, signA );
64 } else {
65 return softfloat_subMagsF64( uiA, uiB, signA );
66 }
67#else
68 magsFuncPtr =
69 (signA == signB) ? softfloat_addMagsF64 : softfloat_subMagsF64;
70 return (*magsFuncPtr)( uiA, uiB, signA );
71#endif
72
73}
float64_t softfloat_subMagsF64(uint_fast64_t, uint_fast64_t, bool)
float64_t softfloat_addMagsF64(uint_fast64_t, uint_fast64_t, bool)
#define signF64UI(a)
Definition internals.h:125
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_div()

float64_t f64_div ( float64_t a,
float64_t b )

Definition at line 44 of file f64_div.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA;
51 union ui64_f64 uB;
52 uint_fast64_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast64_t sigB;
56 bool signZ;
57 struct exp16_sig64 normExpSig;
58 int_fast16_t expZ;
59 uint32_t recip32, sig32Z, doubleTerm;
60 uint_fast64_t rem;
61 uint32_t q;
62 uint_fast64_t sigZ;
63 uint_fast64_t uiZ;
64 union ui64_f64 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 uA.f = a;
69 uiA = uA.ui;
70 signA = signF64UI( uiA );
71 expA = expF64UI( uiA );
72 sigA = fracF64UI( uiA );
73 uB.f = b;
74 uiB = uB.ui;
75 signB = signF64UI( uiB );
76 expB = expF64UI( uiB );
77 sigB = fracF64UI( uiB );
78 signZ = signA ^ signB;
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( expA == 0x7FF ) {
82 if ( sigA ) goto propagateNaN;
83 if ( expB == 0x7FF ) {
84 if ( sigB ) goto propagateNaN;
85 goto invalid;
86 }
87 goto infinity;
88 }
89 if ( expB == 0x7FF ) {
90 if ( sigB ) goto propagateNaN;
91 goto zero;
92 }
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 if ( ! expB ) {
96 if ( ! sigB ) {
97 if ( ! (expA | sigA) ) goto invalid;
99 goto infinity;
100 }
101 normExpSig = softfloat_normSubnormalF64Sig( sigB );
102 expB = normExpSig.exp;
103 sigB = normExpSig.sig;
104 }
105 if ( ! expA ) {
106 if ( ! sigA ) goto zero;
107 normExpSig = softfloat_normSubnormalF64Sig( sigA );
108 expA = normExpSig.exp;
109 sigA = normExpSig.sig;
110 }
111 /*------------------------------------------------------------------------
112 *------------------------------------------------------------------------*/
113 expZ = expA - expB + 0x3FE;
114 sigA |= UINT64_C( 0x0010000000000000 );
115 sigB |= UINT64_C( 0x0010000000000000 );
116 if ( sigA < sigB ) {
117 --expZ;
118 sigA <<= 11;
119 } else {
120 sigA <<= 10;
121 }
122 sigB <<= 11;
123 recip32 = softfloat_approxRecip32_1( sigB>>32 ) - 2;
124 sig32Z = ((uint32_t) (sigA>>32) * (uint_fast64_t) recip32)>>32;
125 doubleTerm = sig32Z<<1;
126 rem =
127 ((sigA - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
128 - (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
129 q = (((uint32_t) (rem>>32) * (uint_fast64_t) recip32)>>32) + 4;
130 sigZ = ((uint_fast64_t) sig32Z<<32) + ((uint_fast64_t) q<<4);
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 if ( (sigZ & 0x1FF) < 4<<4 ) {
134 q &= ~7;
135 sigZ &= ~(uint_fast64_t) 0x7F;
136 doubleTerm = q<<1;
137 rem =
138 ((rem - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
139 - (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
140 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
141 sigZ -= 1<<7;
142 } else {
143 if ( rem ) sigZ |= 1;
144 }
145 }
146 return softfloat_roundPackToF64( signZ, expZ, sigZ );
147 /*------------------------------------------------------------------------
148 *------------------------------------------------------------------------*/
149 propagateNaN:
150 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
151 goto uiZ;
152 /*------------------------------------------------------------------------
153 *------------------------------------------------------------------------*/
154 invalid:
156 uiZ = defaultNaNF64UI;
157 goto uiZ;
158 /*------------------------------------------------------------------------
159 *------------------------------------------------------------------------*/
160 infinity:
161 uiZ = packToF64UI( signZ, 0x7FF, 0 );
162 goto uiZ;
163 /*------------------------------------------------------------------------
164 *------------------------------------------------------------------------*/
165 zero:
166 uiZ = packToF64UI( signZ, 0, 0 );
167 uiZ:
168 uZ.ui = uiZ;
169 return uZ.f;
170
171}
uint_fast64_t softfloat_propagateNaNF64UI(uint_fast64_t uiA, uint_fast64_t uiB)
#define defaultNaNF64UI
Definition specialize.h:158
struct exp16_sig64 softfloat_normSubnormalF64Sig(uint_fast64_t)
#define expF64UI(a)
Definition internals.h:126
#define fracF64UI(a)
Definition internals.h:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_eq()

bool f64_eq ( float64_t a,
float64_t b )

Definition at line 44 of file f64_eq.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
56 if (
58 ) {
60 }
61 return false;
62 }
63 return (uiA == uiB) || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ));
64
65}
#define softfloat_isSigNaNF64UI(uiA)
Definition specialize.h:165
#define isNaNF64UI(a)
Definition internals.h:130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_eq_signaling()

bool f64_eq_signaling ( float64_t a,
float64_t b )

Definition at line 43 of file f64_eq_signaling.c.

44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 union ui64_f64 uB;
48 uint_fast64_t uiB;
49
50 uA.f = a;
51 uiA = uA.ui;
52 uB.f = b;
53 uiB = uB.ui;
54 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
56 return false;
57 }
58 return (uiA == uiB) || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ));
59
60}
Here is the call graph for this function:

◆ f64_is_nan()

bool f64_is_nan ( const float64_t f)
inline

Definition at line 269 of file softfloat.hpp.

269 {
270 return ((f.v & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000);
271}

◆ f64_isSignalingNaN()

bool f64_isSignalingNaN ( float64_t a)

Definition at line 43 of file f64_isSignalingNaN.c.

44{
45 union ui64_f64 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF64UI( uA.ui );
49
50}

◆ f64_le()

bool f64_le ( float64_t a,
float64_t b )

Definition at line 43 of file f64_le.c.

44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 union ui64_f64 uB;
48 uint_fast64_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
57 return false;
58 }
59 signA = signF64UI( uiA );
60 signB = signF64UI( uiB );
61 return
62 (signA != signB)
63 ? signA || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
64 : (uiA == uiB) || (signA ^ (uiA < uiB));
65
66}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_le_quiet()

bool f64_le_quiet ( float64_t a,
float64_t b )

Definition at line 44 of file f64_le_quiet.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
57 if (
59 ) {
61 }
62 return false;
63 }
64 signA = signF64UI( uiA );
65 signB = signF64UI( uiB );
66 return
67 (signA != signB)
68 ? signA || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
69 : (uiA == uiB) || (signA ^ (uiA < uiB));
70
71}
Here is the call graph for this function:

◆ f64_lt()

bool f64_lt ( float64_t a,
float64_t b )

Definition at line 43 of file f64_lt.c.

44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 union ui64_f64 uB;
48 uint_fast64_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
57 return false;
58 }
59 signA = signF64UI( uiA );
60 signB = signF64UI( uiB );
61 return
62 (signA != signB)
63 ? signA && ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
64 : (uiA != uiB) && (signA ^ (uiA < uiB));
65
66}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_lt_quiet()

bool f64_lt_quiet ( float64_t a,
float64_t b )

Definition at line 44 of file f64_lt_quiet.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
57 if (
59 ) {
61 }
62 return false;
63 }
64 signA = signF64UI( uiA );
65 signB = signF64UI( uiB );
66 return
67 (signA != signB)
68 ? signA && ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
69 : (uiA != uiB) && (signA ^ (uiA < uiB));
70
71}
Here is the call graph for this function:

◆ f64_mul()

float64_t f64_mul ( float64_t a,
float64_t b )

Definition at line 44 of file f64_mul.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA;
51 union ui64_f64 uB;
52 uint_fast64_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast64_t sigB;
56 bool signZ;
57 uint_fast64_t magBits;
58 struct exp16_sig64 normExpSig;
59 int_fast16_t expZ;
60#ifdef SOFTFLOAT_FAST_INT64
61 struct uint128 sig128Z;
62#else
63 uint32_t sig128Z[4];
64#endif
65 uint_fast64_t sigZ, uiZ;
66 union ui64_f64 uZ;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 uA.f = a;
71 uiA = uA.ui;
72 signA = signF64UI( uiA );
73 expA = expF64UI( uiA );
74 sigA = fracF64UI( uiA );
75 uB.f = b;
76 uiB = uB.ui;
77 signB = signF64UI( uiB );
78 expB = expF64UI( uiB );
79 sigB = fracF64UI( uiB );
80 signZ = signA ^ signB;
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 if ( expA == 0x7FF ) {
84 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
85 magBits = expB | sigB;
86 goto infArg;
87 }
88 if ( expB == 0x7FF ) {
89 if ( sigB ) goto propagateNaN;
90 magBits = expA | sigA;
91 goto infArg;
92 }
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 if ( ! expA ) {
96 if ( ! sigA ) goto zero;
97 normExpSig = softfloat_normSubnormalF64Sig( sigA );
98 expA = normExpSig.exp;
99 sigA = normExpSig.sig;
100 }
101 if ( ! expB ) {
102 if ( ! sigB ) goto zero;
103 normExpSig = softfloat_normSubnormalF64Sig( sigB );
104 expB = normExpSig.exp;
105 sigB = normExpSig.sig;
106 }
107 /*------------------------------------------------------------------------
108 *------------------------------------------------------------------------*/
109 expZ = expA + expB - 0x3FF;
110 sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
111 sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<11;
112#ifdef SOFTFLOAT_FAST_INT64
113 sig128Z = softfloat_mul64To128( sigA, sigB );
114 sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
115#else
116 softfloat_mul64To128M( sigA, sigB, sig128Z );
117 sigZ =
118 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
119 if ( sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )] ) sigZ |= 1;
120#endif
121 if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
122 --expZ;
123 sigZ <<= 1;
124 }
125 return softfloat_roundPackToF64( signZ, expZ, sigZ );
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 propagateNaN:
129 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
130 goto uiZ;
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 infArg:
134 if ( ! magBits ) {
136 uiZ = defaultNaNF64UI;
137 } else {
138 uiZ = packToF64UI( signZ, 0x7FF, 0 );
139 }
140 goto uiZ;
141 /*------------------------------------------------------------------------
142 *------------------------------------------------------------------------*/
143 zero:
144 uiZ = packToF64UI( signZ, 0, 0 );
145 uiZ:
146 uZ.ui = uiZ;
147 return uZ.f;
148
149}
void softfloat_mul64To128M(uint64_t a, uint64_t b, uint32_t *zPtr)
struct uint128 softfloat_mul64To128(uint64_t a, uint64_t b)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_mulAdd()

float64_t f64_mulAdd ( float64_t a,
float64_t b,
float64_t c )

Definition at line 42 of file f64_mulAdd.c.

43{
44 union ui64_f64 uA;
45 uint_fast64_t uiA;
46 union ui64_f64 uB;
47 uint_fast64_t uiB;
48 union ui64_f64 uC;
49 uint_fast64_t uiC;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 uC.f = c;
56 uiC = uC.ui;
57 return softfloat_mulAddF64( uiA, uiB, uiC, 0 );
58
59}
float64_t softfloat_mulAddF64(uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast8_t)
Here is the call graph for this function:

◆ f64_negative_infinity()

float64_t f64_negative_infinity ( )
inline

Definition at line 282 of file softfloat.hpp.

282 {
283 return {0xfff0000000000000ull};
284}

◆ f64_positive_infinity()

float64_t f64_positive_infinity ( )
inline

Definition at line 285 of file softfloat.hpp.

285 {
286 return {0x7ff0000000000000ull};
287}

◆ f64_rem()

float64_t f64_rem ( float64_t a,
float64_t b )

Definition at line 44 of file f64_rem.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA;
51 union ui64_f64 uB;
52 uint_fast64_t uiB;
53 int_fast16_t expB;
54 uint_fast64_t sigB;
55 struct exp16_sig64 normExpSig;
56 uint64_t rem;
57 int_fast16_t expDiff;
58 uint32_t q, recip32;
59 uint_fast64_t q64;
60 uint64_t altRem, meanRem;
61 bool signRem;
62 uint_fast64_t uiZ;
63 union ui64_f64 uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 uA.f = a;
68 uiA = uA.ui;
69 signA = signF64UI( uiA );
70 expA = expF64UI( uiA );
71 sigA = fracF64UI( uiA );
72 uB.f = b;
73 uiB = uB.ui;
74 expB = expF64UI( uiB );
75 sigB = fracF64UI( uiB );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( expA == 0x7FF ) {
79 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
80 goto invalid;
81 }
82 if ( expB == 0x7FF ) {
83 if ( sigB ) goto propagateNaN;
84 return a;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( expA < expB - 1 ) return a;
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( ! expB ) {
92 if ( ! sigB ) goto invalid;
93 normExpSig = softfloat_normSubnormalF64Sig( sigB );
94 expB = normExpSig.exp;
95 sigB = normExpSig.sig;
96 }
97 if ( ! expA ) {
98 if ( ! sigA ) return a;
99 normExpSig = softfloat_normSubnormalF64Sig( sigA );
100 expA = normExpSig.exp;
101 sigA = normExpSig.sig;
102 }
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 rem = sigA | UINT64_C( 0x0010000000000000 );
106 sigB |= UINT64_C( 0x0010000000000000 );
107 expDiff = expA - expB;
108 if ( expDiff < 1 ) {
109 if ( expDiff < -1 ) return a;
110 sigB <<= 9;
111 if ( expDiff ) {
112 rem <<= 8;
113 q = 0;
114 } else {
115 rem <<= 9;
116 q = (sigB <= rem);
117 if ( q ) rem -= sigB;
118 }
119 } else {
120 recip32 = softfloat_approxRecip32_1( sigB>>21 );
121 /*--------------------------------------------------------------------
122 | Changing the shift of `rem' here requires also changing the initial
123 | subtraction from `expDiff'.
124 *--------------------------------------------------------------------*/
125 rem <<= 9;
126 expDiff -= 30;
127 /*--------------------------------------------------------------------
128 | The scale of `sigB' affects how many bits are obtained during each
129 | cycle of the loop. Currently this is 29 bits per loop iteration,
130 | the maximum possible.
131 *--------------------------------------------------------------------*/
132 sigB <<= 9;
133 for (;;) {
134 q64 = (uint32_t) (rem>>32) * (uint_fast64_t) recip32;
135 if ( expDiff < 0 ) break;
136 q = (q64 + 0x80000000)>>32;
137#ifdef SOFTFLOAT_FAST_INT64
138 rem <<= 29;
139#else
140 rem = (uint_fast64_t) (uint32_t) (rem>>3)<<32;
141#endif
142 rem -= q * (uint64_t) sigB;
143 if ( rem & UINT64_C( 0x8000000000000000 ) ) rem += sigB;
144 expDiff -= 29;
145 }
146 /*--------------------------------------------------------------------
147 | (`expDiff' cannot be less than -29 here.)
148 *--------------------------------------------------------------------*/
149 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
150 rem = (rem<<(expDiff + 30)) - q * (uint64_t) sigB;
151 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
152 altRem = rem + sigB;
153 goto selectRem;
154 }
155 }
156 /*------------------------------------------------------------------------
157 *------------------------------------------------------------------------*/
158 do {
159 altRem = rem;
160 ++q;
161 rem -= sigB;
162 } while ( ! (rem & UINT64_C( 0x8000000000000000 )) );
163 selectRem:
164 meanRem = rem + altRem;
165 if (
166 (meanRem & UINT64_C( 0x8000000000000000 )) || (! meanRem && (q & 1))
167 ) {
168 rem = altRem;
169 }
170 signRem = signA;
171 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
172 signRem = ! signRem;
173 rem = -rem;
174 }
175 return softfloat_normRoundPackToF64( signRem, expB, rem );
176 /*------------------------------------------------------------------------
177 *------------------------------------------------------------------------*/
178 propagateNaN:
179 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
180 goto uiZ;
181 invalid:
183 uiZ = defaultNaNF64UI;
184 uiZ:
185 uZ.ui = uiZ;
186 return uZ.f;
187
188}
float64_t softfloat_normRoundPackToF64(bool, int_fast16_t, uint_fast64_t)
Here is the call graph for this function:

◆ f64_roundToInt()

float64_t f64_roundToInt ( float64_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f64_roundToInt.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t uiZ, lastBitMask, roundBitsMask;
50 union ui64_f64 uZ;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uA.f = a;
55 uiA = uA.ui;
56 exp = expF64UI( uiA );
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 if ( exp <= 0x3FE ) {
60 if ( !(uiA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) return a;
62 uiZ = uiA & packToF64UI( 1, 0, 0 );
63 switch ( roundingMode ) {
65 if ( !fracF64UI( uiA ) ) break;
67 if ( exp == 0x3FE ) uiZ |= packToF64UI( 0, 0x3FF, 0 );
68 break;
70 if ( uiZ ) uiZ = packToF64UI( 1, 0x3FF, 0 );
71 break;
73 if ( !uiZ ) uiZ = packToF64UI( 0, 0x3FF, 0 );
74 break;
75#ifdef SOFTFLOAT_ROUND_ODD
77 uiZ |= packToF64UI( 0, 0x3FF, 0 );
78 break;
79#endif
80 }
81 goto uiZ;
82 }
83 /*------------------------------------------------------------------------
84 *------------------------------------------------------------------------*/
85 if ( 0x433 <= exp ) {
86 if ( (exp == 0x7FF) && fracF64UI( uiA ) ) {
87 uiZ = softfloat_propagateNaNF64UI( uiA, 0 );
88 goto uiZ;
89 }
90 return a;
91 }
92 /*------------------------------------------------------------------------
93 *------------------------------------------------------------------------*/
94 uiZ = uiA;
95 lastBitMask = (uint_fast64_t) 1<<(0x433 - exp);
96 roundBitsMask = lastBitMask - 1;
97 if ( roundingMode == softfloat_round_near_maxMag ) {
98 uiZ += lastBitMask>>1;
99 } else if ( roundingMode == softfloat_round_near_even ) {
100 uiZ += lastBitMask>>1;
101 if ( !(uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
102 } else if (
103 roundingMode
105 ) {
106 uiZ += roundBitsMask;
107 }
108 uiZ &= ~roundBitsMask;
109 if ( uiZ != uiA ) {
110#ifdef SOFTFLOAT_ROUND_ODD
111 if ( roundingMode == softfloat_round_odd ) uiZ |= lastBitMask;
112#endif
114 }
115 uiZ:
116 uZ.ui = uiZ;
117 return uZ.f;
118
119}
Here is the call graph for this function:

◆ f64_sign_bit()

bool f64_sign_bit ( float64_t f)
inline

Definition at line 263 of file softfloat.hpp.

263{ return f.v >> 63; }

◆ f64_sqrt()

float64_t f64_sqrt ( float64_t a)

Definition at line 44 of file f64_sqrt.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA, uiZ;
51 struct exp16_sig64 normExpSig;
52 int_fast16_t expZ;
53 uint32_t sig32A, recipSqrt32, sig32Z;
54 uint_fast64_t rem;
55 uint32_t q;
56 uint_fast64_t sigZ, shiftedSigZ;
57 union ui64_f64 uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA = uA.ui;
63 signA = signF64UI( uiA );
64 expA = expF64UI( uiA );
65 sigA = fracF64UI( uiA );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 if ( expA == 0x7FF ) {
69 if ( sigA ) {
70 uiZ = softfloat_propagateNaNF64UI( uiA, 0 );
71 goto uiZ;
72 }
73 if ( ! signA ) return a;
74 goto invalid;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( signA ) {
79 if ( ! (expA | sigA) ) return a;
80 goto invalid;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( ! expA ) {
85 if ( ! sigA ) return a;
86 normExpSig = softfloat_normSubnormalF64Sig( sigA );
87 expA = normExpSig.exp;
88 sigA = normExpSig.sig;
89 }
90 /*------------------------------------------------------------------------
91 | (`sig32Z' is guaranteed to be a lower bound on the square root of
92 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
93 | `sigA'.)
94 *------------------------------------------------------------------------*/
95 expZ = ((expA - 0x3FF)>>1) + 0x3FE;
96 expA &= 1;
97 sigA |= UINT64_C( 0x0010000000000000 );
98 sig32A = sigA>>21;
99 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
100 sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
101 if ( expA ) {
102 sigA <<= 8;
103 sig32Z >>= 1;
104 } else {
105 sigA <<= 9;
106 }
107 rem = sigA - (uint_fast64_t) sig32Z * sig32Z;
108 q = ((uint32_t) (rem>>2) * (uint_fast64_t) recipSqrt32)>>32;
109 sigZ = ((uint_fast64_t) sig32Z<<32 | 1<<5) + ((uint_fast64_t) q<<3);
110 /*------------------------------------------------------------------------
111 *------------------------------------------------------------------------*/
112 if ( (sigZ & 0x1FF) < 0x22 ) {
113 sigZ &= ~(uint_fast64_t) 0x3F;
114 shiftedSigZ = sigZ>>6;
115 rem = (sigA<<52) - shiftedSigZ * shiftedSigZ;
116 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
117 --sigZ;
118 } else {
119 if ( rem ) sigZ |= 1;
120 }
121 }
122 return softfloat_roundPackToF64( 0, expZ, sigZ );
123 /*------------------------------------------------------------------------
124 *------------------------------------------------------------------------*/
125 invalid:
127 uiZ = defaultNaNF64UI;
128 uiZ:
129 uZ.ui = uiZ;
130 return uZ.f;
131
132}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_sub()

float64_t f64_sub ( float64_t a,
float64_t b )

Definition at line 43 of file f64_sub.c.

44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 bool signA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52 float64_t (*magsFuncPtr)( uint_fast64_t, uint_fast64_t, bool );
53#endif
54
55 uA.f = a;
56 uiA = uA.ui;
57 signA = signF64UI( uiA );
58 uB.f = b;
59 uiB = uB.ui;
60 signB = signF64UI( uiB );
61#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
62 if ( signA == signB ) {
63 return softfloat_subMagsF64( uiA, uiB, signA );
64 } else {
65 return softfloat_addMagsF64( uiA, uiB, signA );
66 }
67#else
68 magsFuncPtr =
69 (signA == signB) ? softfloat_subMagsF64 : softfloat_addMagsF64;
70 return (*magsFuncPtr)( uiA, uiB, signA );
71#endif
72
73}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_to_f128()

float128_t f64_to_f128 ( float64_t a)

Definition at line 44 of file f64_to_f128.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 struct exp16_sig64 normExpSig;
54 struct uint128 frac128;
55 union ui128_f128 uZ;
56
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 uA.f = a;
60 uiA = uA.ui;
61 sign = signF64UI( uiA );
62 exp = expF64UI( uiA );
63 frac = fracF64UI( uiA );
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( exp == 0x7FF ) {
67 if ( frac ) {
70 } else {
71 uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
72 uiZ.v0 = 0;
73 }
74 goto uiZ;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( ! exp ) {
79 if ( ! frac ) {
80 uiZ.v64 = packToF128UI64( sign, 0, 0 );
81 uiZ.v0 = 0;
82 goto uiZ;
83 }
84 normExpSig = softfloat_normSubnormalF64Sig( frac );
85 exp = normExpSig.exp - 1;
86 frac = normExpSig.sig;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 frac128 = softfloat_shortShiftLeft128( 0, frac, 60 );
91 uiZ.v64 = packToF128UI64( sign, exp + 0x3C00, frac128.v64 );
92 uiZ.v0 = frac128.v0;
93 uiZ:
94 uZ.ui = uiZ;
95 return uZ.f;
96
97}
#define softfloat_f64UIToCommonNaN(uiA, zPtr)
Definition specialize.h:166
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_to_f128M()

void f64_to_f128M ( float64_t a,
float128_t * zPtr )

Definition at line 55 of file f64_to_f128M.c.

56{
57 uint32_t *zWPtr;
58 union ui64_f64 uA;
59 uint64_t uiA;
60 bool sign;
61 int_fast16_t exp;
62 uint64_t frac;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65 struct exp16_sig64 normExpSig;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 zWPtr = (uint32_t *) zPtr;
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uA.f = a;
73 uiA = uA.ui;
74 sign = signF64UI( uiA );
75 exp = expF64UI( uiA );
76 frac = fracF64UI( uiA );
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 zWPtr[indexWord( 4, 0 )] = 0;
80 if ( exp == 0x7FF ) {
81 if ( frac ) {
84 return;
85 }
86 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
87 goto uiZ;
88 }
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( ! exp ) {
92 if ( ! frac ) {
93 uiZ96 = packToF128UI96( sign, 0, 0 );
94 goto uiZ;
95 }
96 normExpSig = softfloat_normSubnormalF64Sig( frac );
97 exp = normExpSig.exp - 1;
98 frac = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 zWPtr[indexWord( 4, 1 )] = (uint32_t) frac<<28;
103 frac >>= 4;
104 zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp + 0x3C00, frac>>32 );
105 zWPtr[indexWord( 4, 2 )] = frac;
106 return;
107 /*------------------------------------------------------------------------
108 *------------------------------------------------------------------------*/
109 uiZ:
110 zWPtr[indexWord( 4, 3 )] = uiZ96;
111 zWPtr[indexWord( 4, 2 )] = 0;
112 zWPtr[indexWord( 4, 1 )] = 0;
113
114}
int_fast16_t exp
Definition internals.h:132
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_to_f16()

float16_t f64_to_f16 ( float64_t a)

Definition at line 44 of file f64_to_f16.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 uint_fast16_t uiZ, frac16;
53 union ui16_f16 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 sign = signF64UI( uiA );
60 exp = expF64UI( uiA );
61 frac = fracF64UI( uiA );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( exp == 0x7FF ) {
65 if ( frac ) {
68 } else {
69 uiZ = packToF16UI( sign, 0x1F, 0 );
70 }
71 goto uiZ;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 frac16 = softfloat_shortShiftRightJam64( frac, 38 );
76 if ( ! (exp | frac16) ) {
77 uiZ = packToF16UI( sign, 0, 0 );
78 goto uiZ;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 return softfloat_roundPackToF16( sign, exp - 0x3F1, frac16 | 0x4000 );
83 uiZ:
84 uZ.ui = uiZ;
85 return uZ.f;
86
87}
Here is the call graph for this function:

◆ f64_to_f32()

float32_t f64_to_f32 ( float64_t a)

Definition at line 44 of file f64_to_f32.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 uint_fast32_t uiZ, frac32;
53 union ui32_f32 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 sign = signF64UI( uiA );
60 exp = expF64UI( uiA );
61 frac = fracF64UI( uiA );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( exp == 0x7FF ) {
65 if ( frac ) {
68 } else {
69 uiZ = packToF32UI( sign, 0xFF, 0 );
70 }
71 goto uiZ;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 frac32 = softfloat_shortShiftRightJam64( frac, 22 );
76 if ( ! (exp | frac32) ) {
77 uiZ = packToF32UI( sign, 0, 0 );
78 goto uiZ;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 return softfloat_roundPackToF32( sign, exp - 0x381, frac32 | 0x40000000 );
83 uiZ:
84 uZ.ui = uiZ;
85 return uZ.f;
86
87}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_to_i32()

int_fast32_t f64_to_i32 ( float64_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f64_to_i32.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA = uA.ui;
57 sign = signF64UI( uiA );
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
63 if ( (exp == 0x7FF) && sig ) {
64#if (i32_fromNaN == i32_fromPosOverflow)
65 sign = 0;
66#elif (i32_fromNaN == i32_fromNegOverflow)
67 sign = 1;
68#else
70 return i32_fromNaN;
71#endif
72 }
73#endif
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
77 shiftDist = 0x427 - exp;
78 if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
79 return softfloat_roundToI32( sign, sig, roundingMode, exact );
80
81}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_to_i32_r_minMag()

int_fast32_t f64_to_i32_r_minMag ( float64_t a,
bool exact )

Definition at line 44 of file f64_to_i32_r_minMag.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x433 - exp;
63 if ( 53 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF64UI( uiA );
72 if ( shiftDist < 22 ) {
73 if (
74 sign && (exp == 0x41E) && (sig < UINT64_C( 0x0000000000200000 ))
75 ) {
76 if ( exact && sig ) {
78 }
79 return -0x7FFFFFFF - 1;
80 }
82 return
83 (exp == 0x7FF) && sig ? i32_fromNaN
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 sig |= UINT64_C( 0x0010000000000000 );
89 absZ = sig>>shiftDist;
90 if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
92 }
93 return sign ? -absZ : absZ;
94
95}
Here is the call graph for this function:

◆ f64_to_i64()

int_fast64_t f64_to_i64 ( float64_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f64_to_i64.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 struct uint64_extra sigExtra;
54#else
55 uint32_t extSig[3];
56#endif
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF64UI( uiA );
63 exp = expF64UI( uiA );
64 sig = fracF64UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
68 shiftDist = 0x433 - exp;
69#ifdef SOFTFLOAT_FAST_INT64
70 if ( shiftDist <= 0 ) {
71 if ( shiftDist < -11 ) goto invalid;
72 sigExtra.v = sig<<-shiftDist;
73 sigExtra.extra = 0;
74 } else {
75 sigExtra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
76 }
77 return
79 sign, sigExtra.v, sigExtra.extra, roundingMode, exact );
80#else
81 extSig[indexWord( 3, 0 )] = 0;
82 if ( shiftDist <= 0 ) {
83 if ( shiftDist < -11 ) goto invalid;
84 sig <<= -shiftDist;
85 extSig[indexWord( 3, 2 )] = sig>>32;
86 extSig[indexWord( 3, 1 )] = sig;
87 } else {
88 extSig[indexWord( 3, 2 )] = sig>>32;
89 extSig[indexWord( 3, 1 )] = sig;
90 softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
91 }
92 return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
93#endif
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 invalid:
98 return
99 (exp == 0x7FF) && fracF64UI( uiA ) ? i64_fromNaN
101
102}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_to_i64_r_minMag()

int_fast64_t f64_to_i64_r_minMag ( float64_t a,
bool exact )

Definition at line 44 of file f64_to_i64_r_minMag.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52 int_fast64_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF64UI( uiA );
59 exp = expF64UI( uiA );
60 sig = fracF64UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0x433 - exp;
64 if ( shiftDist <= 0 ) {
65 /*--------------------------------------------------------------------
66 *--------------------------------------------------------------------*/
67 if ( shiftDist < -10 ) {
68 if ( uiA == packToF64UI( 1, 0x43E, 0 ) ) {
69 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
70 }
72 return
73 (exp == 0x7FF) && sig ? i64_fromNaN
75 }
76 /*--------------------------------------------------------------------
77 *--------------------------------------------------------------------*/
78 sig |= UINT64_C( 0x0010000000000000 );
79 absZ = sig<<-shiftDist;
80 } else {
81 /*--------------------------------------------------------------------
82 *--------------------------------------------------------------------*/
83 if ( 53 <= shiftDist ) {
84 if ( exact && (exp | sig) ) {
86 }
87 return 0;
88 }
89 /*--------------------------------------------------------------------
90 *--------------------------------------------------------------------*/
91 sig |= UINT64_C( 0x0010000000000000 );
92 absZ = sig>>shiftDist;
93 if ( exact && (absZ<<shiftDist != sig) ) {
95 }
96 }
97 return sign ? -absZ : absZ;
98
99}
Here is the call graph for this function:

◆ f64_to_ui32()

uint_fast32_t f64_to_ui32 ( float64_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f64_to_ui32.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA = uA.ui;
57 sign = signF64UI( uiA );
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
63 if ( (exp == 0x7FF) && sig ) {
64#if (ui32_fromNaN == ui32_fromPosOverflow)
65 sign = 0;
66#elif (ui32_fromNaN == ui32_fromNegOverflow)
67 sign = 1;
68#else
70 return ui32_fromNaN;
71#endif
72 }
73#endif
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
77 shiftDist = 0x427 - exp;
78 if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
79 return softfloat_roundToUI32( sign, sig, roundingMode, exact );
80
81}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_to_ui32_r_minMag()

uint_fast32_t f64_to_ui32_r_minMag ( float64_t a,
bool exact )

Definition at line 44 of file f64_to_ui32_r_minMag.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x433 - exp;
63 if ( 53 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF64UI( uiA );
72 if ( sign || (shiftDist < 21) ) {
74 return
75 (exp == 0x7FF) && sig ? ui32_fromNaN
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 sig |= UINT64_C( 0x0010000000000000 );
81 z = sig>>shiftDist;
82 if ( exact && ((uint_fast64_t) z<<shiftDist != sig) ) {
84 }
85 return z;
86
87}
Here is the call graph for this function:

◆ f64_to_ui64()

uint_fast64_t f64_to_ui64 ( float64_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f64_to_ui64.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 struct uint64_extra sigExtra;
54#else
55 uint32_t extSig[3];
56#endif
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF64UI( uiA );
63 exp = expF64UI( uiA );
64 sig = fracF64UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
68 shiftDist = 0x433 - exp;
69#ifdef SOFTFLOAT_FAST_INT64
70 if ( shiftDist <= 0 ) {
71 if ( shiftDist < -11 ) goto invalid;
72 sigExtra.v = sig<<-shiftDist;
73 sigExtra.extra = 0;
74 } else {
75 sigExtra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
76 }
77 return
79 sign, sigExtra.v, sigExtra.extra, roundingMode, exact );
80#else
81 extSig[indexWord( 3, 0 )] = 0;
82 if ( shiftDist <= 0 ) {
83 if ( shiftDist < -11 ) goto invalid;
84 sig <<= -shiftDist;
85 extSig[indexWord( 3, 2 )] = sig>>32;
86 extSig[indexWord( 3, 1 )] = sig;
87 } else {
88 extSig[indexWord( 3, 2 )] = sig>>32;
89 extSig[indexWord( 3, 1 )] = sig;
90 softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
91 }
92 return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
93#endif
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 invalid:
98 return
99 (exp == 0x7FF) && fracF64UI( uiA ) ? ui64_fromNaN
101
102}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f64_to_ui64_r_minMag()

uint_fast64_t f64_to_ui64_r_minMag ( float64_t a,
bool exact )

Definition at line 44 of file f64_to_ui64_r_minMag.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x433 - exp;
63 if ( 53 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF64UI( uiA );
72 if ( sign ) goto invalid;
73 if ( shiftDist <= 0 ) {
74 if ( shiftDist < -11 ) goto invalid;
75 z = (sig | UINT64_C( 0x0010000000000000 ))<<-shiftDist;
76 } else {
77 sig |= UINT64_C( 0x0010000000000000 );
78 z = sig>>shiftDist;
79 if ( exact && (uint64_t) (sig<<(-shiftDist & 63)) ) {
81 }
82 }
83 return z;
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 invalid:
88 return
89 (exp == 0x7FF) && sig ? ui64_fromNaN
91
92}
Here is the call graph for this function:

◆ from_softfloat32()

float from_softfloat32 ( float32_t f)
inline

Definition at line 305 of file softfloat.hpp.

305 {
306 float x;
307 memcpy(&x, &f, sizeof(f));
308 return x;
309}
memcpy((char *) pInfo->slotDescription, s, l)
Here is the call graph for this function:

◆ from_softfloat64()

double from_softfloat64 ( float64_t d)
inline

Definition at line 310 of file softfloat.hpp.

310 {
311 double x;
312 memcpy(&x, &d, sizeof(d));
313 return x;
314}
Here is the call graph for this function:

◆ i32_to_f128()

float128_t i32_to_f128 ( int32_t a)

Definition at line 42 of file i32_to_f128.c.

43{
44 uint_fast64_t uiZ64;
45 bool sign;
46 uint_fast32_t absA;
47 int_fast8_t shiftDist;
48 union ui128_f128 uZ;
49
50 uiZ64 = 0;
51 if ( a ) {
52 sign = (a < 0);
53 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
54 shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
55 uiZ64 =
56 packToF128UI64(
57 sign, 0x402E - shiftDist, (uint_fast64_t) absA<<shiftDist );
58 }
59 uZ.ui.v64 = uiZ64;
60 uZ.ui.v0 = 0;
61 return uZ.f;
62
63}
#define softfloat_countLeadingZeros32
Here is the caller graph for this function:

◆ i32_to_f128M()

void i32_to_f128M ( int32_t a,
float128_t * zPtr )

Definition at line 53 of file i32_to_f128M.c.

54{
55 uint32_t *zWPtr;
56 uint32_t uiZ96, uiZ64;
57 bool sign;
58 uint32_t absA;
59 int_fast8_t shiftDist;
60 uint64_t normAbsA;
61
62 zWPtr = (uint32_t *) zPtr;
63 uiZ96 = 0;
64 uiZ64 = 0;
65 if ( a ) {
66 sign = (a < 0);
67 absA = sign ? -(uint32_t) a : (uint32_t) a;
68 shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
69 normAbsA = (uint64_t) absA<<shiftDist;
70 uiZ96 = packToF128UI96( sign, 0x402E - shiftDist, normAbsA>>32 );
71 uiZ64 = normAbsA;
72 }
73 zWPtr[indexWord( 4, 3 )] = uiZ96;
74 zWPtr[indexWord( 4, 2 )] = uiZ64;
75 zWPtr[indexWord( 4, 1 )] = 0;
76 zWPtr[indexWord( 4, 0 )] = 0;
77
78}

◆ i32_to_f16()

float16_t i32_to_f16 ( int32_t a)

Definition at line 43 of file i32_to_f16.c.

44{
45 bool sign;
46 uint_fast32_t absA;
47 int_fast8_t shiftDist;
48 union ui16_f16 u;
49 uint_fast16_t sig;
50
51 sign = (a < 0);
52 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
53 shiftDist = softfloat_countLeadingZeros32( absA ) - 21;
54 if ( 0 <= shiftDist ) {
55 u.ui =
56 a ? packToF16UI(
57 sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
58 : 0;
59 return u.f;
60 } else {
61 shiftDist += 4;
62 sig =
63 (shiftDist < 0)
64 ? absA>>(-shiftDist)
65 | ((uint32_t) (absA<<(shiftDist & 31)) != 0)
66 : (uint_fast16_t) absA<<shiftDist;
67 return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
68 }
69
70}
Here is the call graph for this function:

◆ i32_to_f32()

float32_t i32_to_f32 ( int32_t a)

Definition at line 43 of file i32_to_f32.c.

44{
45 bool sign;
46 union ui32_f32 uZ;
47 uint_fast32_t absA;
48
49 sign = (a < 0);
50 if ( ! (a & 0x7FFFFFFF) ) {
51 uZ.ui = sign ? packToF32UI( 1, 0x9E, 0 ) : 0;
52 return uZ.f;
53 }
54 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
55 return softfloat_normRoundPackToF32( sign, 0x9C, absA );
56
57}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ i32_to_f64()

float64_t i32_to_f64 ( int32_t a)

Definition at line 43 of file i32_to_f64.c.

44{
45 uint_fast64_t uiZ;
46 bool sign;
47 uint_fast32_t absA;
48 int_fast8_t shiftDist;
49 union ui64_f64 uZ;
50
51 if ( ! a ) {
52 uiZ = 0;
53 } else {
54 sign = (a < 0);
55 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
56 shiftDist = softfloat_countLeadingZeros32( absA ) + 21;
57 uiZ =
59 sign, 0x432 - shiftDist, (uint_fast64_t) absA<<shiftDist );
60 }
61 uZ.ui = uiZ;
62 return uZ.f;
63
64}
uint64_t ui
Definition internals.h:47
Here is the caller graph for this function:

◆ i64_to_f128()

float128_t i64_to_f128 ( int64_t a)

Definition at line 42 of file i64_to_f128.c.

43{
44 uint_fast64_t uiZ64, uiZ0;
45 bool sign;
46 uint_fast64_t absA;
47 int_fast8_t shiftDist;
48 struct uint128 zSig;
49 union ui128_f128 uZ;
50
51 if ( ! a ) {
52 uiZ64 = 0;
53 uiZ0 = 0;
54 } else {
55 sign = (a < 0);
56 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
57 shiftDist = softfloat_countLeadingZeros64( absA ) + 49;
58 if ( 64 <= shiftDist ) {
59 zSig.v64 = absA<<(shiftDist - 64);
60 zSig.v0 = 0;
61 } else {
62 zSig = softfloat_shortShiftLeft128( 0, absA, shiftDist );
63 }
64 uiZ64 = packToF128UI64( sign, 0x406E - shiftDist, zSig.v64 );
65 uiZ0 = zSig.v0;
66 }
67 uZ.ui.v64 = uiZ64;
68 uZ.ui.v0 = uiZ0;
69 return uZ.f;
70
71}
#define softfloat_countLeadingZeros64
Here is the call graph for this function:
Here is the caller graph for this function:

◆ i64_to_f128M()

void i64_to_f128M ( int64_t a,
float128_t * zPtr )

Definition at line 53 of file i64_to_f128M.c.

54{
55 uint32_t *zWPtr;
56 uint32_t uiZ96, uiZ64;
57 bool sign;
58 uint64_t absA;
59 uint_fast8_t shiftDist;
60 uint32_t *ptr;
61
62 zWPtr = (uint32_t *) zPtr;
63 uiZ96 = 0;
64 uiZ64 = 0;
65 zWPtr[indexWord( 4, 1 )] = 0;
66 zWPtr[indexWord( 4, 0 )] = 0;
67 if ( a ) {
68 sign = (a < 0);
69 absA = sign ? -(uint64_t) a : (uint64_t) a;
70 shiftDist = softfloat_countLeadingZeros64( absA ) + 17;
71 if ( shiftDist < 32 ) {
72 ptr = zWPtr + indexMultiwordHi( 4, 3 );
73 ptr[indexWord( 3, 2 )] = 0;
74 ptr[indexWord( 3, 1 )] = absA>>32;
75 ptr[indexWord( 3, 0 )] = absA;
76 softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
77 ptr[indexWordHi( 3 )] =
79 sign, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
80 return;
81 }
82 absA <<= shiftDist - 32;
83 uiZ96 = packToF128UI96( sign, 0x404E - shiftDist, absA>>32 );
84 uiZ64 = absA;
85 }
86 zWPtr[indexWord( 4, 3 )] = uiZ96;
87 zWPtr[indexWord( 4, 2 )] = uiZ64;
88
89}
#define softfloat_shortShiftLeft96M(aPtr, dist, zPtr)
Definition primitives.h:695

◆ i64_to_f16()

float16_t i64_to_f16 ( int64_t a)

Definition at line 43 of file i64_to_f16.c.

44{
45 bool sign;
46 uint_fast64_t absA;
47 int_fast8_t shiftDist;
48 union ui16_f16 u;
49 uint_fast16_t sig;
50
51 sign = (a < 0);
52 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
53 shiftDist = softfloat_countLeadingZeros64( absA ) - 53;
54 if ( 0 <= shiftDist ) {
55 u.ui =
56 a ? packToF16UI(
57 sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
58 : 0;
59 return u.f;
60 } else {
61 shiftDist += 4;
62 sig =
63 (shiftDist < 0)
64 ? softfloat_shortShiftRightJam64( absA, -shiftDist )
65 : (uint_fast16_t) absA<<shiftDist;
66 return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
67 }
68
69}
Here is the call graph for this function:

◆ i64_to_f32()

float32_t i64_to_f32 ( int64_t a)

Definition at line 43 of file i64_to_f32.c.

44{
45 bool sign;
46 uint_fast64_t absA;
47 int_fast8_t shiftDist;
48 union ui32_f32 u;
49 uint_fast32_t sig;
50
51 sign = (a < 0);
52 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
53 shiftDist = softfloat_countLeadingZeros64( absA ) - 40;
54 if ( 0 <= shiftDist ) {
55 u.ui =
56 a ? packToF32UI(
57 sign, 0x95 - shiftDist, (uint_fast32_t) absA<<shiftDist )
58 : 0;
59 return u.f;
60 } else {
61 shiftDist += 7;
62 sig =
63 (shiftDist < 0)
64 ? softfloat_shortShiftRightJam64( absA, -shiftDist )
65 : (uint_fast32_t) absA<<shiftDist;
66 return softfloat_roundPackToF32( sign, 0x9C - shiftDist, sig );
67 }
68
69}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ i64_to_f64()

float64_t i64_to_f64 ( int64_t a)

Definition at line 43 of file i64_to_f64.c.

44{
45 bool sign;
46 union ui64_f64 uZ;
47 uint_fast64_t absA;
48
49 sign = (a < 0);
50 if ( ! (a & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
51 uZ.ui = sign ? packToF64UI( 1, 0x43E, 0 ) : 0;
52 return uZ.f;
53 }
54 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
55 return softfloat_normRoundPackToF64( sign, 0x43C, absA );
56
57}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNaNF128()

bool isNaNF128 ( const float128_t * f)

Definition at line 4 of file f128_isnan.c.

4 {
5 const uint32_t* wptr = (const uint32_t*)f;
6 return softfloat_isNaNF128M( wptr );
7}
Here is the call graph for this function:

◆ operator!=() [1/3]

bool operator!= ( const float128_t & lhs,
const float128_t & rhs )
inline

Definition at line 242 of file softfloat.hpp.

242 {
243 return !f128_eq(lhs, rhs);
244}
bool f128_eq(float128_t, float128_t)
Definition f128_eq.c:44
Here is the call graph for this function:

◆ operator!=() [2/3]

bool operator!= ( const float32_t & lhs,
const float32_t & rhs )
inline

Definition at line 194 of file softfloat.hpp.

194 {
195 return !f32_eq(lhs, rhs);
196}
bool f32_eq(float32_t, float32_t)
Definition f32_eq.c:44
Here is the call graph for this function:

◆ operator!=() [3/3]

bool operator!= ( const float64_t & lhs,
const float64_t & rhs )
inline

Definition at line 218 of file softfloat.hpp.

218 {
219 return !f64_eq(lhs, rhs);
220}
bool f64_eq(float64_t, float64_t)
Definition f64_eq.c:44
Here is the call graph for this function:

◆ operator<() [1/3]

bool operator< ( const float128_t & lhs,
const float128_t & rhs )
inline

Definition at line 246 of file softfloat.hpp.

246 {
247 return f128_lt(lhs, rhs);
248}
bool f128_lt(float128_t, float128_t)
Definition f128_lt.c:43
Here is the call graph for this function:

◆ operator<() [2/3]

bool operator< ( const float32_t & lhs,
const float32_t & rhs )
inline

Definition at line 198 of file softfloat.hpp.

198 {
199 return f32_lt(lhs, rhs);
200}
bool f32_lt(float32_t, float32_t)
Definition f32_lt.c:43
Here is the call graph for this function:

◆ operator<() [3/3]

bool operator< ( const float64_t & lhs,
const float64_t & rhs )
inline

Definition at line 222 of file softfloat.hpp.

222 {
223 return f64_lt(lhs, rhs);
224}
bool f64_lt(float64_t, float64_t)
Definition f64_lt.c:43
Here is the call graph for this function:

◆ operator<=() [1/3]

bool operator<= ( const float128_t & lhs,
const float128_t & rhs )
inline

Definition at line 254 of file softfloat.hpp.

254 {
255 return f128_le(lhs, rhs);
256}
bool f128_le(float128_t, float128_t)
Definition f128_le.c:43
Here is the call graph for this function:

◆ operator<=() [2/3]

bool operator<= ( const float32_t & lhs,
const float32_t & rhs )
inline

Definition at line 206 of file softfloat.hpp.

206 {
207 return f32_le(lhs, rhs);
208}
bool f32_le(float32_t, float32_t)
Definition f32_le.c:43
Here is the call graph for this function:

◆ operator<=() [3/3]

bool operator<= ( const float64_t & lhs,
const float64_t & rhs )
inline

Definition at line 230 of file softfloat.hpp.

230 {
231 return f64_le(lhs, rhs);
232}
bool f64_le(float64_t, float64_t)
Definition f64_le.c:43
Here is the call graph for this function:

◆ operator==() [1/3]

bool operator== ( const float128_t & lhs,
const float128_t & rhs )
inline

Definition at line 238 of file softfloat.hpp.

238 {
239 return f128_eq(lhs, rhs);
240}
Here is the call graph for this function:

◆ operator==() [2/3]

bool operator== ( const float32_t & lhs,
const float32_t & rhs )
inline

Definition at line 190 of file softfloat.hpp.

190 {
191 return f32_eq(lhs, rhs);
192}
Here is the call graph for this function:

◆ operator==() [3/3]

bool operator== ( const float64_t & lhs,
const float64_t & rhs )
inline

Definition at line 214 of file softfloat.hpp.

214 {
215 return f64_eq(lhs, rhs);
216}
Here is the call graph for this function:

◆ operator>() [1/3]

bool operator> ( const float128_t & lhs,
const float128_t & rhs )
inline

Definition at line 250 of file softfloat.hpp.

250 {
251 return f128_lt(rhs, lhs);
252}
Here is the call graph for this function:

◆ operator>() [2/3]

bool operator> ( const float32_t & lhs,
const float32_t & rhs )
inline

Definition at line 202 of file softfloat.hpp.

202 {
203 return f32_lt(rhs, lhs);
204}
Here is the call graph for this function:

◆ operator>() [3/3]

bool operator> ( const float64_t & lhs,
const float64_t & rhs )
inline

Definition at line 226 of file softfloat.hpp.

226 {
227 return f64_lt(rhs, lhs);
228}
Here is the call graph for this function:

◆ operator>=() [1/3]

bool operator>= ( const float128_t & lhs,
const float128_t & rhs )
inline

Definition at line 258 of file softfloat.hpp.

258 {
259 return f128_le(rhs, lhs);
260}
Here is the call graph for this function:

◆ operator>=() [2/3]

bool operator>= ( const float32_t & lhs,
const float32_t & rhs )
inline

Definition at line 210 of file softfloat.hpp.

210 {
211 return f32_le(rhs, lhs);
212}
Here is the call graph for this function:

◆ operator>=() [3/3]

bool operator>= ( const float64_t & lhs,
const float64_t & rhs )
inline

Definition at line 234 of file softfloat.hpp.

234 {
235 return f64_le(rhs, lhs);
236}
Here is the call graph for this function:

◆ to_softfloat32()

float32_t to_softfloat32 ( float f)
inline

Definition at line 295 of file softfloat.hpp.

295 {
296 float32_t x;
297 memcpy(&x, &f, sizeof(f));
298 return x;
299}
Here is the call graph for this function:

◆ to_softfloat64()

float64_t to_softfloat64 ( double d)
inline

Definition at line 300 of file softfloat.hpp.

300 {
301 float64_t x;
302 memcpy(&x, &d, sizeof(d));
303 return x;
304}
Here is the call graph for this function:

◆ ui32_to_f128()

float128_t ui32_to_f128 ( uint32_t a)

Definition at line 42 of file ui32_to_f128.c.

43{
44 uint_fast64_t uiZ64;
45 int_fast8_t shiftDist;
46 union ui128_f128 uZ;
47
48 uiZ64 = 0;
49 if ( a ) {
50 shiftDist = softfloat_countLeadingZeros32( a ) + 17;
51 uiZ64 =
52 packToF128UI64(
53 0, 0x402E - shiftDist, (uint_fast64_t) a<<shiftDist );
54 }
55 uZ.ui.v64 = uiZ64;
56 uZ.ui.v0 = 0;
57 return uZ.f;
58
59}

◆ ui32_to_f128M()

void ui32_to_f128M ( uint32_t a,
float128_t * zPtr )

Definition at line 53 of file ui32_to_f128M.c.

54{
55 uint32_t *zWPtr, uiZ96, uiZ64;
56 int_fast8_t shiftDist;
57 uint64_t normA;
58
59 zWPtr = (uint32_t *) zPtr;
60 uiZ96 = 0;
61 uiZ64 = 0;
62 if ( a ) {
63 shiftDist = softfloat_countLeadingZeros32( a ) + 17;
64 normA = (uint64_t) a<<shiftDist;
65 uiZ96 = packToF128UI96( 0, 0x402E - shiftDist, normA>>32 );
66 uiZ64 = normA;
67 }
68 zWPtr[indexWord( 4, 3 )] = uiZ96;
69 zWPtr[indexWord( 4, 2 )] = uiZ64;
70 zWPtr[indexWord( 4, 1 )] = 0;
71 zWPtr[indexWord( 4, 0 )] = 0;
72
73}

◆ ui32_to_f16()

float16_t ui32_to_f16 ( uint32_t a)

Definition at line 42 of file ui32_to_f16.c.

43{
44 int_fast8_t shiftDist;
45 union ui16_f16 u;
46 uint_fast16_t sig;
47
48 shiftDist = softfloat_countLeadingZeros32( a ) - 21;
49 if ( 0 <= shiftDist ) {
50 u.ui =
51 a ? packToF16UI(
52 0, 0x18 - shiftDist, (uint_fast16_t) a<<shiftDist )
53 : 0;
54 return u.f;
55 } else {
56 shiftDist += 4;
57 sig =
58 (shiftDist < 0)
59 ? a>>(-shiftDist) | ((uint32_t) (a<<(shiftDist & 31)) != 0)
60 : (uint_fast16_t) a<<shiftDist;
61 return softfloat_roundPackToF16( 0, 0x1C - shiftDist, sig );
62 }
63
64}
Here is the call graph for this function:

◆ ui32_to_f32()

float32_t ui32_to_f32 ( uint32_t a)

Definition at line 42 of file ui32_to_f32.c.

43{
44 union ui32_f32 uZ;
45
46 if ( ! a ) {
47 uZ.ui = 0;
48 return uZ.f;
49 }
50 if ( a & 0x80000000 ) {
51 return softfloat_roundPackToF32( 0, 0x9D, a>>1 | (a & 1) );
52 } else {
53 return softfloat_normRoundPackToF32( 0, 0x9C, a );
54 }
55
56}
Here is the call graph for this function:

◆ ui32_to_f64()

float64_t ui32_to_f64 ( uint32_t a)

Definition at line 42 of file ui32_to_f64.c.

43{
44 uint_fast64_t uiZ;
45 int_fast8_t shiftDist;
46 union ui64_f64 uZ;
47
48 if ( ! a ) {
49 uiZ = 0;
50 } else {
51 shiftDist = softfloat_countLeadingZeros32( a ) + 21;
52 uiZ =
53 packToF64UI( 0, 0x432 - shiftDist, (uint_fast64_t) a<<shiftDist );
54 }
55 uZ.ui = uiZ;
56 return uZ.f;
57
58}

◆ ui64_to_f128()

float128_t ui64_to_f128 ( uint64_t a)

Definition at line 42 of file ui64_to_f128.c.

43{
44 uint_fast64_t uiZ64, uiZ0;
45 int_fast8_t shiftDist;
46 struct uint128 zSig;
47 union ui128_f128 uZ;
48
49 if ( ! a ) {
50 uiZ64 = 0;
51 uiZ0 = 0;
52 } else {
53 shiftDist = softfloat_countLeadingZeros64( a ) + 49;
54 if ( 64 <= shiftDist ) {
55 zSig.v64 = a<<(shiftDist - 64);
56 zSig.v0 = 0;
57 } else {
58 zSig = softfloat_shortShiftLeft128( 0, a, shiftDist );
59 }
60 uiZ64 = packToF128UI64( 0, 0x406E - shiftDist, zSig.v64 );
61 uiZ0 = zSig.v0;
62 }
63 uZ.ui.v64 = uiZ64;
64 uZ.ui.v0 = uiZ0;
65 return uZ.f;
66
67}
Here is the call graph for this function:

◆ ui64_to_f128M()

void ui64_to_f128M ( uint64_t a,
float128_t * zPtr )

Definition at line 53 of file ui64_to_f128M.c.

54{
55 uint32_t *zWPtr, uiZ96, uiZ64;
56 uint_fast8_t shiftDist;
57 uint32_t *ptr;
58
59 zWPtr = (uint32_t *) zPtr;
60 uiZ96 = 0;
61 uiZ64 = 0;
62 zWPtr[indexWord( 4, 1 )] = 0;
63 zWPtr[indexWord( 4, 0 )] = 0;
64 if ( a ) {
65 shiftDist = softfloat_countLeadingZeros64( a ) + 17;
66 if ( shiftDist < 32 ) {
67 ptr = zWPtr + indexMultiwordHi( 4, 3 );
68 ptr[indexWord( 3, 2 )] = 0;
69 ptr[indexWord( 3, 1 )] = a>>32;
70 ptr[indexWord( 3, 0 )] = a;
71 softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
72 ptr[indexWordHi( 3 )] =
73 packToF128UI96( 0, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
74 return;
75 }
76 a <<= shiftDist - 32;
77 uiZ96 = packToF128UI96( 0, 0x404E - shiftDist, a>>32 );
78 uiZ64 = a;
79 }
80 zWPtr[indexWord( 4, 3 )] = uiZ96;
81 zWPtr[indexWord( 4, 2 )] = uiZ64;
82
83}

◆ ui64_to_f16()

float16_t ui64_to_f16 ( uint64_t a)

Definition at line 42 of file ui64_to_f16.c.

43{
44 int_fast8_t shiftDist;
45 union ui16_f16 u;
46 uint_fast16_t sig;
47
48 shiftDist = softfloat_countLeadingZeros64( a ) - 53;
49 if ( 0 <= shiftDist ) {
50 u.ui =
51 a ? packToF16UI(
52 0, 0x18 - shiftDist, (uint_fast16_t) a<<shiftDist )
53 : 0;
54 return u.f;
55 } else {
56 shiftDist += 4;
57 sig =
58 (shiftDist < 0) ? softfloat_shortShiftRightJam64( a, -shiftDist )
59 : (uint_fast16_t) a<<shiftDist;
60 return softfloat_roundPackToF16( 0, 0x1C - shiftDist, sig );
61 }
62
63}
Here is the call graph for this function:

◆ ui64_to_f32()

float32_t ui64_to_f32 ( uint64_t a)

Definition at line 42 of file ui64_to_f32.c.

43{
44 int_fast8_t shiftDist;
45 union ui32_f32 u;
46 uint_fast32_t sig;
47
48 shiftDist = softfloat_countLeadingZeros64( a ) - 40;
49 if ( 0 <= shiftDist ) {
50 u.ui =
51 a ? packToF32UI(
52 0, 0x95 - shiftDist, (uint_fast32_t) a<<shiftDist )
53 : 0;
54 return u.f;
55 } else {
56 shiftDist += 7;
57 sig =
58 (shiftDist < 0) ? softfloat_shortShiftRightJam64( a, -shiftDist )
59 : (uint_fast32_t) a<<shiftDist;
60 return softfloat_roundPackToF32( 0, 0x9C - shiftDist, sig );
61 }
62
63}
Here is the call graph for this function:

◆ ui64_to_f64()

float64_t ui64_to_f64 ( uint64_t a)

Definition at line 42 of file ui64_to_f64.c.

43{
44 union ui64_f64 uZ;
45
46 if ( ! a ) {
47 uZ.ui = 0;
48 return uZ.f;
49 }
50 if ( a & UINT64_C( 0x8000000000000000 ) ) {
51 return
53 0, 0x43D, softfloat_shortShiftRightJam64( a, 1 ) );
54 } else {
55 return softfloat_normRoundPackToF64( 0, 0x43C, a );
56 }
57
58}
Here is the call graph for this function: