Skip to content

Commit

Permalink
fpu/softfloat.c: Return correctly signed values from uint64_to_float32
Browse files Browse the repository at this point in the history
The uint64_to_float32() conversion function was incorrectly always
returning numbers with the sign bit set (ie negative numbers). Correct
this so we return positive numbers instead.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
  • Loading branch information
pm215 authored and aurel32 committed Oct 1, 2012
1 parent 4be8eea commit e744c06
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fpu/softfloat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ float32 uint64_to_float32( uint64 a STATUS_PARAM )
if ( a == 0 ) return float32_zero;
shiftCount = countLeadingZeros64( a ) - 40;
if ( 0 <= shiftCount ) {
return packFloat32( 1 > 0, 0x95 - shiftCount, a<<shiftCount );
return packFloat32(0, 0x95 - shiftCount, a<<shiftCount);
}
else {
shiftCount += 7;
Expand All @@ -1248,7 +1248,7 @@ float32 uint64_to_float32( uint64 a STATUS_PARAM )
else {
a <<= shiftCount;
}
return roundAndPackFloat32( 1 > 0, 0x9C - shiftCount, a STATUS_VAR );
return roundAndPackFloat32(0, 0x9C - shiftCount, a STATUS_VAR);
}
}

Expand Down

0 comments on commit e744c06

Please sign in to comment.