This repository was archived by the owner on May 21, 2019. It is now read-only.
File tree 2 files changed +8
-22
lines changed
2 files changed +8
-22
lines changed Original file line number Diff line number Diff line change @@ -35,17 +35,11 @@ fp_t __floatsidf(int a) {
35
35
const int exponent = (aWidth - 1 ) - __builtin_clz (a );
36
36
rep_t result ;
37
37
38
- // Shift a into the significand field, rounding if it is a right-shift
39
- if (exponent <= significandBits ) {
40
- const int shift = significandBits - exponent ;
41
- result = (rep_t )a << shift ^ implicitBit ;
42
- } else {
43
- const int shift = exponent - significandBits ;
44
- result = (rep_t )a >> shift ^ implicitBit ;
45
- rep_t round = (rep_t )a << (typeWidth - shift );
46
- if (round > signBit ) result ++ ;
47
- if (round == signBit ) result += result & 1 ;
48
- }
38
+ // Shift a into the significand field and clear the implicit bit. Extra
39
+ // cast to unsigned int is necessary to get the correct behavior for
40
+ // the input INT_MIN.
41
+ const int shift = significandBits - exponent ;
42
+ result = (rep_t )(unsigned int )a << shift ^ implicitBit ;
49
43
50
44
// Insert the exponent
51
45
result += (rep_t )(exponent + exponentBias ) << significandBits ;
Original file line number Diff line number Diff line change @@ -27,17 +27,9 @@ fp_t __floatunsidf(unsigned int a) {
27
27
const int exponent = (aWidth - 1 ) - __builtin_clz (a );
28
28
rep_t result ;
29
29
30
- // Shift a into the significand field, rounding if it is a right-shift
31
- if (exponent <= significandBits ) {
32
- const int shift = significandBits - exponent ;
33
- result = (rep_t )a << shift ^ implicitBit ;
34
- } else {
35
- const int shift = exponent - significandBits ;
36
- result = (rep_t )a >> shift ^ implicitBit ;
37
- rep_t round = (rep_t )a << (typeWidth - shift );
38
- if (round > signBit ) result ++ ;
39
- if (round == signBit ) result += result & 1 ;
40
- }
30
+ // Shift a into the significand field and clear the implicit bit.
31
+ const int shift = significandBits - exponent ;
32
+ result = (rep_t )a << shift ^ implicitBit ;
41
33
42
34
// Insert the exponent
43
35
result += (rep_t )(exponent + exponentBias ) << significandBits ;
You can’t perform that action at this time.
0 commit comments