Skip to content

Commit

Permalink
Fix string float detection
Browse files Browse the repository at this point in the history
  • Loading branch information
donhardman committed Apr 6, 2021
1 parent 189ec1d commit 6f7bef5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/BinaryCodec.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ protected function getDataFormat(mixed &$data): string {
$data = hex2bin($val);
break;

case is_numeric($data) && str_contains($data, '.') && (ltrim($data, '0')[0] === '.' || $data[0] !== '0'):
case is_numeric($data) && str_contains($data, '.') && (ltrim($data, '0')[0] === '.' || $data[0] !== '0') && trim($data, '0..9.') === '':
$fraction = strlen($data) - strpos($data, '.') - 1;
$val = gmp_strval(gmp_init(bcmul($data, gmp_strval(gmp_pow(10, $fraction)), 0), 10), 16);
if (strlen($val) % 2 !== 0) {
Expand Down

0 comments on commit 6f7bef5

Please sign in to comment.