Skip to contentSkip to conversation

softfloat: fix mask in extractFloat32Exp

PATCH In review Alexander Aring 2 participants 3 messages Mar 29, 2013 – Apr 5, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 softfloat: fix mask in extractFloat32Exp

This will fix the mask of extractFloat32Exp from 0xFF to 0x7F. On bit 0x80 is the sign bit of IEEE 754.

---
 fpu/softfloat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fpu/softfloat.c +1 -1
index 83ccc4b..4e8ed79 100644
@@ -221,7 +221,7 @@ INLINE uint32_t extractFloat32Frac( float32 a )
 INLINE int_fast16_t extractFloat32Exp(float32 a)
 {
 
-    return ( float32_val(a)>>23 ) & 0xFF;
+    return ( float32_val(a)>>23 ) & 0x7F;
 
 }
 
Signature · 1 line
1.8.2
#1 lore raw
Quoted 13 lines · Alexander Aring

This will fix the mask of extractFloat32Exp from 0xFF to 0x7F. On bit 0x80 is the sign bit of IEEE 754.

---
 fpu/softfloat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fpu/softfloat.c +0 -0
index 83ccc4b..4e8ed79 100644

fpu/softfloat.c INLINE uint32_t extractFloat32Frac( float32 a ) · line 224

Quoted 5 lines
fpu/softfloat.c +1 -1
@@ -221,7 +221,7 @@ INLINE uint32_t extractFloat32Frac( float32 a )
 INLINE int_fast16_t extractFloat32Exp(float32 a)
 {
 
-    return ( float32_val(a)>>23 ) & 0xFF;
+    return ( float32_val(a)>>23 ) & 0x7F;

This patch seems wrong because the fraction is 23 bits, exponent is 8 bits, and sign is 1 bit.

IEEE 754 Binary32 representation:
SEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFF
3 2 0
0 3

http://en.wikipedia.org/wiki/Binary32

Since the exponent is *8* bits, 0xFF is correct. The sign bit is 0x100 after >>23.

Stefan

#2 lore raw

Hi,

Quoted 9 lines · Stefan Hajnoczi

This patch seems wrong because the fraction is 23 bits, exponent is 8 bits, and sign is 1 bit.

IEEE 754 Binary32 representation:
SEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFF
3 2 0
0 3

Quoted 5 lines

http://en.wikipedia.org/wiki/Binary32

Since the exponent is *8* bits, 0xFF is correct. The sign bit is 0x100 after >>23.

ahh, I see it! Sorry for the noise :)

Alex