2e6f4b046e804ead926d4193e5475889db1dafe2
[riscv-isa-sim.git] / softfloat / s_normRoundPackToF32.c
1
2 #include <stdbool.h>
3 #include <stdint.h>
4 #include "platform.h"
5 #include "primitives.h"
6 #include "internals.h"
7
8 float32_t
9 softfloat_normRoundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
10 {
11 int shiftCount;
12 union ui32_f32 uZ;
13
14 shiftCount = softfloat_countLeadingZeros32( sig ) - 1;
15 exp -= shiftCount;
16 if ( ( 7 <= shiftCount ) && ( (uint16_t) exp < 0xFD ) ) {
17 uZ.ui = packToF32UI( sign, sig ? exp : 0, sig<<( shiftCount - 7 ) );
18 return uZ.f;
19 } else {
20 return softfloat_roundPackToF32( sign, exp, sig<<shiftCount );
21 }
22
23 }
24