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

Go to the source code of this file.

Functions

int_fast32_t f128_to_i32 (float128_t a, uint_fast8_t roundingMode, bool exact)
 

Function Documentation

◆ f128_to_i32()

int_fast32_t f128_to_i32 ( float128_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f128_to_i32.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
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA64 = uA.ui.v64;
57 uiA0 = uA.ui.v0;
58 sign = signF128UI64( uiA64 );
59 exp = expF128UI64( uiA64 );
60 sig64 = fracF128UI64( uiA64 );
61 sig0 = uiA0;
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
65 if ( (exp == 0x7FFF) && (sig64 | sig0) ) {
66#if (i32_fromNaN == i32_fromPosOverflow)
67 sign = 0;
68#elif (i32_fromNaN == i32_fromNegOverflow)
69 sign = 1;
70#else
72 return i32_fromNaN;
73#endif
74 }
75#endif
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
79 sig64 |= (sig0 != 0);
80 shiftDist = 0x4023 - exp;
81 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
82 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
83
84}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
void softfloat_raiseFlags(uint_fast8_t flags)
#define i32_fromNaN
Definition specialize.h:59
int_fast32_t softfloat_roundToI32(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:
Here is the caller graph for this function: