Subject: | Bug - Must allocate extra space to receive valid data in conversion from hex to decimal |
Date: | Tue, 30 Sep 2008 12:57:54 -0500 |
To: | "bug-Bit-Vector [...] rt.cpan.org" <bug-Bit-Vector [...] rt.cpan.org> |
From: | Stephen P Gray <Stephen.Gray [...] maxim-ic.com> |
When declaring a new_Hex item one must pad at least one extra bit in the size field or when converting to decimal the value returned is invalid.
Show quoted text
>>> Code >>>
my $hex = '966104526fe7d8baac32d27124a467b8';
my $vec = Bit::Vector->new_Hex(128, $hex);
print "128 bits - $hex => " . $vec->to_Dec() . "\n";
my $vec2 = Bit::Vector->new_Hex(129, $hex);
print "129 bits - $hex => " . $vec2->to_Dec() . "\n";
<<< End Code <<<
Show quoted text>>> Output >>>
128 bits - 966104526fe7d8baac32d27124a467b8 => -140394427096942342042315520958275491912
129 bits - 966104526fe7d8baac32d27124a467b8 => 199887939823996121421059086473492719544
<<< End Output <<<
OS: SunOS caddo 5.8 Generic_117350-36 sun4u sparc
Perl::Version: 5.8.1
Bit::Vector::Version: 6.4
Stephen P. Gray
Maxim Integrated Products
Test Engineer I
(972) 371-4631
Stephen.Gray@maxim-ic.com