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

Go to the source code of this file.

Functions

int_fast32_t f16_to_i32 (float16_t a, uint_fast8_t roundingMode, bool exact)
 

Function Documentation

◆ f16_to_i32()

int_fast32_t f16_to_i32 ( float16_t a,
uint_fast8_t roundingMode,
bool exact )

Definition at line 44 of file f16_to_i32.c.

45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 int_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
65 return
66 frac ? i32_fromNaN
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( 0 <= shiftDist ) {
76 sig32 <<= shiftDist;
77 return sign ? -sig32 : sig32;
78 }
79 shiftDist = exp - 0x0D;
80 if ( 0 < shiftDist ) sig32 <<= shiftDist;
81 }
82 return
84 sign, (uint_fast32_t) sig32, roundingMode, exact );
85
86}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
void softfloat_raiseFlags(uint_fast8_t flags)
#define i32_fromNegOverflow
Definition specialize.h:58
#define i32_fromNaN
Definition specialize.h:59
#define i32_fromPosOverflow
Definition specialize.h:57
#define expF16UI(a)
Definition internals.h:84
#define signF16UI(a)
Definition internals.h:83
#define fracF16UI(a)
Definition internals.h:85
int_fast32_t softfloat_roundToI32(bool, uint_fast64_t, uint_fast8_t, bool)
@ softfloat_flag_invalid
Definition softfloat.h:89
uint16_t uint_fast16_t
Definition stdint.h:155
int8_t int_fast8_t
Definition stdint.h:150
uint32_t uint_fast32_t
Definition stdint.h:156
int32_t int_fast32_t
Definition stdint.h:152
float16_t f
Definition internals.h:45
Here is the call graph for this function: