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

Go to the source code of this file.

Functions

float32_t f32_mul (float32_t a, float32_t b)
 

Function Documentation

◆ f32_mul()

float32_t f32_mul ( float32_t a,
float32_t b )

Definition at line 44 of file f32_mul.c.

45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 union ui32_f32 uB;
52 uint_fast32_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast32_t sigB;
56 bool signZ;
57 uint_fast32_t magBits;
58 struct exp16_sig32 normExpSig;
59 int_fast16_t expZ;
60 uint_fast32_t sigZ, uiZ;
61 union ui32_f32 uZ;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 uA.f = a;
66 uiA = uA.ui;
67 signA = signF32UI( uiA );
68 expA = expF32UI( uiA );
69 sigA = fracF32UI( uiA );
70 uB.f = b;
71 uiB = uB.ui;
72 signB = signF32UI( uiB );
73 expB = expF32UI( uiB );
74 sigB = fracF32UI( uiB );
75 signZ = signA ^ signB;
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( expA == 0xFF ) {
79 if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
80 magBits = expB | sigB;
81 goto infArg;
82 }
83 if ( expB == 0xFF ) {
84 if ( sigB ) goto propagateNaN;
85 magBits = expA | sigA;
86 goto infArg;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! expA ) {
91 if ( ! sigA ) goto zero;
92 normExpSig = softfloat_normSubnormalF32Sig( sigA );
93 expA = normExpSig.exp;
94 sigA = normExpSig.sig;
95 }
96 if ( ! expB ) {
97 if ( ! sigB ) goto zero;
98 normExpSig = softfloat_normSubnormalF32Sig( sigB );
99 expB = normExpSig.exp;
100 sigB = normExpSig.sig;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 expZ = expA + expB - 0x7F;
105 sigA = (sigA | 0x00800000)<<7;
106 sigB = (sigB | 0x00800000)<<8;
107 sigZ = softfloat_shortShiftRightJam64( (uint_fast64_t) sigA * sigB, 32 );
108 if ( sigZ < 0x40000000 ) {
109 --expZ;
110 sigZ <<= 1;
111 }
112 return softfloat_roundPackToF32( signZ, expZ, sigZ );
113 /*------------------------------------------------------------------------
114 *------------------------------------------------------------------------*/
115 propagateNaN:
116 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
117 goto uiZ;
118 /*------------------------------------------------------------------------
119 *------------------------------------------------------------------------*/
120 infArg:
121 if ( ! magBits ) {
123 uiZ = defaultNaNF32UI;
124 } else {
125 uiZ = packToF32UI( signZ, 0xFF, 0 );
126 }
127 goto uiZ;
128 /*------------------------------------------------------------------------
129 *------------------------------------------------------------------------*/
130 zero:
131 uiZ = packToF32UI( signZ, 0, 0 );
132 uiZ:
133 uZ.ui = uiZ;
134 return uZ.f;
135
136}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
uint_fast32_t softfloat_propagateNaNF32UI(uint_fast32_t uiA, uint_fast32_t uiB)
void softfloat_raiseFlags(uint_fast8_t flags)
#define defaultNaNF32UI
Definition specialize.h:123
#define expF32UI(a)
Definition internals.h:105
float32_t softfloat_roundPackToF32(bool, int_fast16_t, uint_fast32_t)
struct exp16_sig32 softfloat_normSubnormalF32Sig(uint_fast32_t)
#define fracF32UI(a)
Definition internals.h:106
#define signF32UI(a)
Definition internals.h:104
#define packToF32UI(sign, exp, sig)
Definition internals.h:107
uint64_t softfloat_shortShiftRightJam64(uint64_t a, uint_fast8_t dist)
@ softfloat_flag_invalid
Definition softfloat.h:89
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: