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

Go to the source code of this file.

Functions

float32_t f64_to_f32 (float64_t a)
 

Function Documentation

◆ f64_to_f32()

float32_t f64_to_f32 ( float64_t a)

Definition at line 44 of file f64_to_f32.c.

45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 uint_fast32_t uiZ, frac32;
53 union ui32_f32 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 sign = signF64UI( uiA );
60 exp = expF64UI( uiA );
61 frac = fracF64UI( uiA );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( exp == 0x7FF ) {
65 if ( frac ) {
68 } else {
69 uiZ = packToF32UI( sign, 0xFF, 0 );
70 }
71 goto uiZ;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 frac32 = softfloat_shortShiftRightJam64( frac, 22 );
76 if ( ! (exp | frac32) ) {
77 uiZ = packToF32UI( sign, 0, 0 );
78 goto uiZ;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 return softfloat_roundPackToF32( sign, exp - 0x381, frac32 | 0x40000000 );
83 uiZ:
84 uZ.ui = uiZ;
85 return uZ.f;
86
87}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
#define softfloat_f64UIToCommonNaN(uiA, zPtr)
Definition specialize.h:166
#define softfloat_commonNaNToF32UI(aPtr)
Definition specialize.h:137
float32_t softfloat_roundPackToF32(bool, int_fast16_t, uint_fast32_t)
#define signF64UI(a)
Definition internals.h:125
#define expF64UI(a)
Definition internals.h:126
#define fracF64UI(a)
Definition internals.h:127
#define packToF32UI(sign, exp, sig)
Definition internals.h:107
uint64_t softfloat_shortShiftRightJam64(uint64_t a, uint_fast8_t dist)
uint64_t uint_fast64_t
Definition stdint.h:157
uint32_t uint_fast32_t
Definition stdint.h:156
int16_t int_fast16_t
Definition stdint.h:151
float32_t f
Definition internals.h:46
Here is the call graph for this function: