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

Go to the source code of this file.

Functions

float64_t f128_to_f64 (float128_t a)
 

Function Documentation

◆ f128_to_f64()

float64_t f128_to_f64 ( float128_t a)

Definition at line 44 of file f128_to_f64.c.

45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64, frac0;
51 struct commonNaN commonNaN;
52 uint_fast64_t uiZ;
53 struct uint128 frac128;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.ui.v64;
60 uiA0 = uA.ui.v0;
61 sign = signF128UI64( uiA64 );
62 exp = expF128UI64( uiA64 );
63 frac64 = fracF128UI64( uiA64 );
64 frac0 = uiA0;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp == 0x7FFF ) {
68 if ( frac64 | frac0 ) {
71 } else {
72 uiZ = packToF64UI( sign, 0x7FF, 0 );
73 }
74 goto uiZ;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 frac128 = softfloat_shortShiftLeft128( frac64, frac0, 14 );
79 frac64 = frac128.v64 | (frac128.v0 != 0);
80 if ( ! (exp | frac64) ) {
81 uiZ = packToF64UI( sign, 0, 0 );
82 goto uiZ;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 exp -= 0x3C01;
87 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
88 if ( exp < -0x1000 ) exp = -0x1000;
89 }
90 return
92 sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 uiZ:
96 uZ.ui = uiZ;
97 return uZ.f;
98
99}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
void softfloat_f128UIToCommonNaN(uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr)
#define softfloat_commonNaNToF64UI(aPtr)
Definition specialize.h:172
float64_t softfloat_roundPackToF64(bool, int_fast16_t, uint_fast64_t)
#define packToF64UI(sign, exp, sig)
Definition internals.h:128
struct uint128 softfloat_shortShiftLeft128(uint64_t a64, uint64_t a0, uint_fast8_t dist)
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
float64_t f
Definition internals.h:47
Here is the call graph for this function: