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

Go to the source code of this file.

Functions

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

Function Documentation

◆ 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}
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
uint_fast64_t softfloat_roundToUI64(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: