Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
i32_to_f16.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include "platform.h"
#include "internals.h"
#include "softfloat.h"
Include dependency graph for i32_to_f16.c:

Go to the source code of this file.

Functions

float16_t i32_to_f16 (int32_t a)
 

Function Documentation

◆ i32_to_f16()

float16_t i32_to_f16 ( int32_t a)

Definition at line 43 of file i32_to_f16.c.

44{
45 bool sign;
46 uint_fast32_t absA;
47 int_fast8_t shiftDist;
48 union ui16_f16 u;
49 uint_fast16_t sig;
50
51 sign = (a < 0);
52 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
53 shiftDist = softfloat_countLeadingZeros32( absA ) - 21;
54 if ( 0 <= shiftDist ) {
55 u.ui =
56 a ? packToF16UI(
57 sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
58 : 0;
59 return u.f;
60 } else {
61 shiftDist += 4;
62 sig =
63 (shiftDist < 0)
64 ? absA>>(-shiftDist)
65 | ((uint32_t) (absA<<(shiftDist & 31)) != 0)
66 : (uint_fast16_t) absA<<shiftDist;
67 return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
68 }
69
70}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
float16_t softfloat_roundPackToF16(bool, int_fast16_t, uint_fast16_t)
#define packToF16UI(sign, exp, sig)
Definition internals.h:86
#define softfloat_countLeadingZeros32
unsigned int uint32_t
Definition stdint.h:126
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
Here is the call graph for this function: