MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / softfloat_roundPackToExtF80

Function softfloat_roundPackToExtF80

lib/softfloat/source/s_roundPackToExtF80.c:43–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41#include "softfloat.h"
42
43extFloat80_t
44 softfloat_roundPackToExtF80(
45 bool sign,
46 int_fast32_t exp,
47 uint_fast64_t sig,
48 uint_fast64_t sigExtra,
49 uint_fast8_t roundingPrecision
50 )
51{
52 uint_fast8_t roundingMode;
53 bool roundNearEven;
54 uint_fast64_t roundIncrement, roundMask, roundBits;
55 bool isTiny, doIncrement;
56 struct uint64_extra sig64Extra;
57 union { struct extFloat80M s; extFloat80_t f; } uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 roundingMode = softfloat_roundingMode;
62 roundNearEven = (roundingMode == softfloat_round_near_even);
63 if ( roundingPrecision == 80 ) goto precision80;
64 if ( roundingPrecision == 64 ) {
65 roundIncrement = UINT64_C( 0x0000000000000400 );
66 roundMask = UINT64_C( 0x00000000000007FF );
67 } else if ( roundingPrecision == 32 ) {
68 roundIncrement = UINT64_C( 0x0000008000000000 );
69 roundMask = UINT64_C( 0x000000FFFFFFFFFF );
70 } else {
71 goto precision80;
72 }
73 sig |= (sigExtra != 0);
74 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
75 roundIncrement =
76 (roundingMode
77 == (sign ? softfloat_round_min : softfloat_round_max))
78 ? roundMask
79 : 0;
80 }
81 roundBits = sig & roundMask;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
85 if ( exp <= 0 ) {
86 /*----------------------------------------------------------------
87 *----------------------------------------------------------------*/
88 isTiny =
89 (softfloat_detectTininess
90 == softfloat_tininess_beforeRounding)
91 || (exp < 0)
92 || (sig <= (uint64_t) (sig + roundIncrement));
93 sig = softfloat_shiftRightJam64( sig, 1 - exp );
94 roundBits = sig & roundMask;
95 if ( roundBits ) {
96 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
97 softfloat_exceptionFlags |= softfloat_flag_inexact;
98#ifdef SOFTFLOAT_ROUND_ODD
99 if ( roundingMode == softfloat_round_odd ) {
100 sig |= roundMask + 1;

Callers 5

extF80_mulFunction · 0.85
softfloat_addMagsExtF80Function · 0.85
extF80_divFunction · 0.85
extF80_sqrtFunction · 0.85

Calls 3

softfloat_raiseFlagsFunction · 0.50

Tested by

no test coverage detected