Subject: | unpack_float: $decimal_magnitude not handled correctly |
Whenever $decimal_magnitude is supposed to start with a zero, the
leading zeros are omitted. A possible fix is to use sprintf to pad the
number with leading zeros:
sub unpack_float
{
...
if($binary_magnitude) {
$decimal_magnitude = $binary_magnitude . '0'x20; # twenty digit
decimal results
$dm = $decimal_magnitude/$binary_divider;
$decimal_magnitude =
Math::BigInt->new($decimal_magnitude)->bdiv($binary_divider)->bstr();
### FIX: ADD FOLLOWING BLOCK ###
if (length($decimal_magnitude) < 20) {
$decimal_magnitude = sprintf "%.20d", $decimal_magnitude;
}
### FIX: END OF BLOCK ###
}
else {
$decimal_magnitude = 0;
}
...
}