diff --git a/src/Utils.php b/src/Utils.php index 9abd5dc..6cbd1f9 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -118,7 +118,7 @@ class Utils if (!is_string($value)) { throw new InvalidArgumentException('The value to zeroPrefixed function must be string.'); } - return (strpos($value, '0x') === 0) ; + return (strpos($value, '0x') === 0); } /** @@ -392,7 +392,7 @@ class Utils } elseif (is_string($number)) { $number = mb_strtolower($number); - if (self::isZeroPrefixed($number)) { + if (self::isZeroPrefixed($number) || preg_match('/[a-f]+/', $number) === 1) { $number = self::stripZero($number); $bn = new BigNumber($number, 16); } else { diff --git a/test/unit/UtilsTest.php b/test/unit/UtilsTest.php index de95360..18863c8 100644 --- a/test/unit/UtilsTest.php +++ b/test/unit/UtilsTest.php @@ -406,5 +406,9 @@ class UtilsTest extends TestCase $bn = Utils::toBn(0x12); $this->assertEquals($bn->toString(), '18'); + + $bn = Utils::toBn('ae'); + + $this->assertEquals($bn->toString(), '174'); } } \ No newline at end of file