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

Go to the source code of this file.

Functions

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

Function Documentation

◆ 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}
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
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)
struct uint128 softfloat_shortShiftLeft128(uint64_t a64, uint64_t a0, uint_fast8_t dist)
uint64_t uint_fast64_t
Definition stdint.h:157
#define UINT64_C(val)
Definition stdint.h:284
int32_t int_fast32_t
Definition stdint.h:152
Here is the call graph for this function: