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

Go to the source code of this file.

Functions

int_fast32_t f128M_to_i32 (const float128_t *aPtr, uint_fast8_t roundingMode, bool exact)
 

Function Documentation

◆ f128M_to_i32()

int_fast32_t f128M_to_i32 ( const float128_t * aPtr,
uint_fast8_t roundingMode,
bool exact )

Definition at line 57 of file f128M_to_i32.c.

58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint64_t sig64;
64 int32_t shiftDist;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
73 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
77 if ( (exp == 0x7FFF) && sig64 ) {
78#if (i32_fromNaN == i32_fromPosOverflow)
79 sign = 0;
80#elif (i32_fromNaN == i32_fromNegOverflow)
81 sign = 1;
82#else
84 return i32_fromNaN;
85#endif
86 }
87#endif
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
91 shiftDist = 0x4023 - exp;
92 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
93 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
94
95}
void softfloat_raiseFlags(uint_fast8_t flags)
#define i32_fromNaN
Definition specialize.h:59
#define fracF128UI96(a96)
Definition internals.h:249
#define signF128UI96(a96)
Definition internals.h:247
int_fast32_t softfloat_roundToI32(bool, uint_fast64_t, uint_fast8_t, bool)
#define expF128UI96(a96)
Definition internals.h:248
#define indexWord(total, n)
#define indexWordHi(total)
uint64_t softfloat_shiftRightJam64(uint64_t a, uint_fast32_t dist)
@ softfloat_flag_invalid
Definition softfloat.h:89
unsigned int uint32_t
Definition stdint.h:126
#define UINT64_C(val)
Definition stdint.h:284
signed int int32_t
Definition stdint.h:123
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function: