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

Go to the source code of this file.

Functions

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

Function Documentation

◆ 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}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
void softfloat_raiseFlags(uint_fast8_t flags)
#define ui32_fromNaN
Definition specialize.h:56
uint_fast32_t softfloat_roundToUI32(bool, uint_fast64_t, uint_fast8_t, bool)
uint64_t softfloat_shiftRightJam64(uint64_t a, uint_fast32_t dist)
@ softfloat_flag_invalid
Definition softfloat.h:89
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: