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

Go to the source code of this file.

Functions

uint_fast64_t f128_to_ui64_r_minMag (float128_t a, bool exact)
 

Function Documentation

◆ 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}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
void softfloat_raiseFlags(uint_fast8_t flags)
#define ui64_fromPosOverflow
Definition specialize.h:65
#define ui64_fromNegOverflow
Definition specialize.h:66
#define ui64_fromNaN
Definition specialize.h:67
@ softfloat_flag_invalid
Definition softfloat.h:89
@ softfloat_flag_inexact
Definition softfloat.h:85
THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags
uint64_t uint_fast64_t
Definition stdint.h:157
int8_t int_fast8_t
Definition stdint.h:150
#define UINT64_C(val)
Definition stdint.h:284
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: