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

Go to the source code of this file.

Functions

float16_t extF80_to_f16 (extFloat80_t a)
 

Function Documentation

◆ extF80_to_f16()

float16_t extF80_to_f16 ( extFloat80_t a)

Definition at line 44 of file extF80_to_f16.c.

45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 struct commonNaN commonNaN;
53 uint_fast16_t uiZ, sig16;
54 union ui16_f16 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 uiA0 = uA.s.signif;
61 sign = signExtF80UI64( uiA64 );
62 exp = expExtF80UI64( uiA64 );
63 sig = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( exp == 0x7FFF ) {
67 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
70 } else {
71 uiZ = packToF16UI( sign, 0x1F, 0 );
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 sig16 = softfloat_shortShiftRightJam64( sig, 49 );
78 if ( ! (exp | sig16) ) {
79 uiZ = packToF16UI( sign, 0, 0 );
80 goto uiZ;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 exp -= 0x3FF1;
85 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
86 if ( exp < -0x40 ) exp = -0x40;
87 }
88 return softfloat_roundPackToF16( sign, exp, sig16 );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
void softfloat_extF80UIToCommonNaN(uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr)
#define softfloat_commonNaNToF16UI(aPtr)
Definition specialize.h:102
float16_t softfloat_roundPackToF16(bool, int_fast16_t, uint_fast16_t)
#define expExtF80UI64(a64)
Definition internals.h:147
#define signExtF80UI64(a64)
Definition internals.h:146
#define packToF16UI(sign, exp, sig)
Definition internals.h:86
uint64_t softfloat_shortShiftRightJam64(uint64_t a, uint_fast8_t dist)
uint16_t uint_fast16_t
Definition stdint.h:155
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
int16_t int_fast16_t
Definition stdint.h:151
float16_t f
Definition internals.h:45
char * s
Here is the call graph for this function: