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

Go to the source code of this file.

Functions

float64_t softfloat_addMagsF64 (uint_fast64_t uiA, uint_fast64_t uiB, bool signZ)
 

Function Documentation

◆ softfloat_addMagsF64()

float64_t softfloat_addMagsF64 ( uint_fast64_t uiA,
uint_fast64_t uiB,
bool signZ )

Definition at line 44 of file s_addMagsF64.c.

45{
46 int_fast16_t expA;
47 uint_fast64_t sigA;
48 int_fast16_t expB;
49 uint_fast64_t sigB;
50 int_fast16_t expDiff;
51 uint_fast64_t uiZ;
52 int_fast16_t expZ;
53 uint_fast64_t sigZ;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 expA = expF64UI( uiA );
59 sigA = fracF64UI( uiA );
60 expB = expF64UI( uiB );
61 sigB = fracF64UI( uiB );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 expDiff = expA - expB;
65 if ( ! expDiff ) {
66 /*--------------------------------------------------------------------
67 *--------------------------------------------------------------------*/
68 if ( ! expA ) {
69 uiZ = uiA + sigB;
70 goto uiZ;
71 }
72 if ( expA == 0x7FF ) {
73 if ( sigA | sigB ) goto propagateNaN;
74 uiZ = uiA;
75 goto uiZ;
76 }
77 expZ = expA;
78 sigZ = UINT64_C( 0x0020000000000000 ) + sigA + sigB;
79 sigZ <<= 9;
80 } else {
81 /*--------------------------------------------------------------------
82 *--------------------------------------------------------------------*/
83 sigA <<= 9;
84 sigB <<= 9;
85 if ( expDiff < 0 ) {
86 if ( expB == 0x7FF ) {
87 if ( sigB ) goto propagateNaN;
88 uiZ = packToF64UI( signZ, 0x7FF, 0 );
89 goto uiZ;
90 }
91 expZ = expB;
92 if ( expA ) {
93 sigA += UINT64_C( 0x2000000000000000 );
94 } else {
95 sigA <<= 1;
96 }
97 sigA = softfloat_shiftRightJam64( sigA, -expDiff );
98 } else {
99 if ( expA == 0x7FF ) {
100 if ( sigA ) goto propagateNaN;
101 uiZ = uiA;
102 goto uiZ;
103 }
104 expZ = expA;
105 if ( expB ) {
106 sigB += UINT64_C( 0x2000000000000000 );
107 } else {
108 sigB <<= 1;
109 }
110 sigB = softfloat_shiftRightJam64( sigB, expDiff );
111 }
112 sigZ = UINT64_C( 0x2000000000000000 ) + sigA + sigB;
113 if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
114 --expZ;
115 sigZ <<= 1;
116 }
117 }
118 return softfloat_roundPackToF64( signZ, expZ, sigZ );
119 /*------------------------------------------------------------------------
120 *------------------------------------------------------------------------*/
121 propagateNaN:
122 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
123 uiZ:
124 uZ.ui = uiZ;
125 return uZ.f;
126
127}
uint_fast64_t softfloat_propagateNaNF64UI(uint_fast64_t uiA, uint_fast64_t uiB)
float64_t softfloat_roundPackToF64(bool, int_fast16_t, uint_fast64_t)
#define packToF64UI(sign, exp, sig)
Definition internals.h:128
#define expF64UI(a)
Definition internals.h:126
#define fracF64UI(a)
Definition internals.h:127
uint64_t softfloat_shiftRightJam64(uint64_t a, uint_fast32_t dist)
uint64_t uint_fast64_t
Definition stdint.h:157
#define UINT64_C(val)
Definition stdint.h:284
int16_t int_fast16_t
Definition stdint.h:151