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

Go to the source code of this file.

Functions

int_fast32_t extF80M_to_i32_r_minMag (const extFloat80_t *aPtr, bool exact)
 

Function Documentation

◆ extF80M_to_i32_r_minMag()

int_fast32_t extF80M_to_i32_r_minMag ( const extFloat80_t * aPtr,
bool exact )

Definition at line 55 of file extF80M_to_i32_r_minMag.c.

56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 int32_t exp;
60 uint64_t sig;
61 int32_t shiftDist;
62 bool sign, raiseInexact;
63 int32_t z;
64 uint64_t shiftedSig;
65 uint32_t absZ;
66 union { uint32_t ui; int32_t i; } u;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 aSPtr = (const struct extFloat80M *) aPtr;
71 uiA64 = aSPtr->signExp;
72 exp = expExtF80UI64( uiA64 );
73 sig = aSPtr->signif;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! sig && (exp != 0x7FFF) ) return 0;
77 shiftDist = 0x403E - exp;
78 if ( 64 <= shiftDist ) {
79 raiseInexact = exact;
80 z = 0;
81 } else {
82 sign = signExtF80UI64( uiA64 );
83 raiseInexact = false;
84 if ( shiftDist < 0 ) {
85 if ( sig>>32 || (shiftDist <= -31) ) goto invalid;
86 shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
87 if ( shiftedSig>>32 ) goto invalid;
88 absZ = shiftedSig;
89 } else {
90 shiftedSig = sig;
91 if ( shiftDist ) shiftedSig >>= shiftDist;
92 if ( shiftedSig>>32 ) goto invalid;
93 absZ = shiftedSig;
94 if ( exact && shiftDist ) {
95 raiseInexact = ((uint64_t) absZ<<shiftDist != sig);
96 }
97 }
98 if ( sign ) {
99 if ( 0x80000000 < absZ ) goto invalid;
100 u.ui = -absZ;
101 z = u.i;
102 } else {
103 if ( 0x80000000 <= absZ ) goto invalid;
104 z = absZ;
105 }
106 }
108 return z;
109 /*------------------------------------------------------------------------
110 *------------------------------------------------------------------------*/
111 invalid:
113 return
114 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
116
117}
void softfloat_raiseFlags(uint_fast8_t flags)
#define i32_fromNegOverflow
Definition specialize.h:58
#define i32_fromNaN
Definition specialize.h:59
#define i32_fromPosOverflow
Definition specialize.h:57
#define expExtF80UI64(a64)
Definition internals.h:147
#define signExtF80UI64(a64)
Definition internals.h:146
@ softfloat_flag_invalid
Definition softfloat.h:89
@ softfloat_flag_inexact
Definition softfloat.h:85
THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags
unsigned int uint32_t
Definition stdint.h:126
uint16_t uint_fast16_t
Definition stdint.h:155
#define UINT64_C(val)
Definition stdint.h:284
signed int int32_t
Definition stdint.h:123
unsigned __int64 uint64_t
Definition stdint.h:136
uint64_t signif
uint16_t signExp
Here is the call graph for this function: