Permalink
Browse files

- fixed bug # 18037

git-svn-id: http://svn.php.net/repository/pear/packages/Math_BigInteger/trunk@305326 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent de6c399 commit ca70b62d561a9ed7d83c3612c7f3ae6d8160edde @terrafrost terrafrost committed Nov 13, 2010
Showing with 3 additions and 1 deletion.
  1. +3 −1 BigInteger.php
View
@@ -599,7 +599,9 @@ function toBits($twos_compliment = false)
for ($i = 0, $end = strlen($hex) & 0xFFFFFFF8; $i < $end; $i+=8) {
$bits.= str_pad(decbin(hexdec(substr($hex, $i, 8))), 32, '0', STR_PAD_LEFT);
}
- $bits.= str_pad(decbin(hexdec(substr($hex, $end))), strlen($hex) & 7, '0', STR_PAD_LEFT);
+ if ($end != strlen($hex)) { // hexdec('') == 0
+ $bits.= str_pad(decbin(hexdec(substr($hex, $end))), strlen($hex) & 7, '0', STR_PAD_LEFT);
+ }
return $this->precision > 0 ? substr($bits, -$this->precision) : ltrim($bits, '0');
}

0 comments on commit ca70b62

Please sign in to comment.