aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Brunie <nicolas.brunie@sifive.com>2023-09-22 18:30:13 -0700
committerNicolas Brunie <nicolas.brunie@sifive.com>2023-09-22 18:30:13 -0700
commitb1bbccf04d6b350fd5019f9e23ad9c8ae82c9b03 (patch)
treed3fc494503d58235a7fc6eaccd902dfaaf6381fb
parent577fcd787c172e996633016c912dc4795f8d7b7a (diff)
downloadberkeley-softfloat-3-b1bbccf04d6b350fd5019f9e23ad9c8ae82c9b03.zip
berkeley-softfloat-3-b1bbccf04d6b350fd5019f9e23ad9c8ae82c9b03.tar.gz
berkeley-softfloat-3-b1bbccf04d6b350fd5019f9e23ad9c8ae82c9b03.tar.bz2
fixing bf16_to_f32 for subnormal numbers
-rw-r--r--source/bf16_to_f32.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/source/bf16_to_f32.c b/source/bf16_to_f32.c
index a76632e..b86482c 100644
--- a/source/bf16_to_f32.c
+++ b/source/bf16_to_f32.c
@@ -74,17 +74,11 @@ float32_t bf16_to_f32( bfloat16_t a )
}
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- if ( ! exp ) {
- if ( ! frac ) {
- uiZ = packToF32UI( sign, 0, 0 );
- goto uiZ;
- }
- normExpSig = softfloat_normSubnormalBF16Sig( frac );
- exp = normExpSig.exp - 1;
- frac = normExpSig.sig;
- }
- /*------------------------------------------------------------------------
- *------------------------------------------------------------------------*/
+ // packToF32UI simply packs bitfields without any numerical change
+ // which means it can be used directly for any BF16 to f32 conversions which
+ // does not require bits manipulation
+ // (that is everything where the 16-bit are just padded right with 16 zeros, including
+ // subnormal numbers)
uiZ = packToF32UI( sign, exp, ((uint_fast32_t) frac) <<16 );
uiZ:
uZ.ui = uiZ;