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

Go to the source code of this file.

Functions

int_fast32_t f64_to_i32 (float64_t a, uint_fast8_t roundingMode, bool exact)
 

Function Documentation

◆ f64_to_i32()

int_fast32_t f64_to_i32 ( float64_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f64_to_i32.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA = uA.ui;
57 sign = signF64UI( uiA );
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
63 if ( (exp == 0x7FF) && sig ) {
64#if (i32_fromNaN == i32_fromPosOverflow)
65 sign = 0;
66#elif (i32_fromNaN == i32_fromNegOverflow)
67 sign = 1;
68#else
70 return i32_fromNaN;
71#endif
72 }
73#endif
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
77 shiftDist = 0x427 - exp;
78 if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
79 return softfloat_roundToI32( sign, sig, roundingMode, exact );
80
81}
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
#define signF64UI(a)
Definition internals.h:125
#define expF64UI(a)
Definition internals.h:126
int_fast32_t softfloat_roundToI32(bool, uint_fast64_t, uint_fast8_t, bool)
#define fracF64UI(a)
Definition internals.h:127
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
int16_t int_fast16_t
Definition stdint.h:151
float64_t f
Definition internals.h:47
Here is the call graph for this function: