Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
f128_to_i64_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_i64_r_minMag.c:

Go to the source code of this file.

Functions

int_fast64_t f128_to_i64_r_minMag (float128_t a, bool exact)
 

Function Documentation

◆ 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}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
void softfloat_raiseFlags(uint_fast8_t flags)
#define i64_fromNaN
Definition specialize.h:70
#define i64_fromNegOverflow
Definition specialize.h:69
#define i64_fromPosOverflow
Definition specialize.h:68
@ softfloat_flag_invalid
Definition softfloat.h:89
@ softfloat_flag_inexact
Definition softfloat.h:85
THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags
#define INT64_C(val)
Definition stdint.h:279
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
int64_t int_fast64_t
Definition stdint.h:153
Here is the call graph for this function: