m1ome / iso8583

PHP ISO8583 pack/unpack library
MIT License
14 stars 17 forks source link

base_convert precision #2

Closed kaperys closed 7 years ago

kaperys commented 7 years ago

Consider the following hexadecimal bitmap: f23e4491a8e08020

The following binary bitmap is the correct representation of the above hexadecimal one: 11110010 00111110 01000100 10010001 10101000 11100000 10000000 00100000

The following binary bitmap is the outcome of using PHP's base_convert function to represent the above hexadecimal one: 11110010 00111110 01000100 10010001 10101000 11100000 10000000 00000000

Notice how bit 59 is ON in the correct bitmap, and OFF in PHP's.

This is due to PHP's base_convert function losing precision when working with data of a length greater than 32 bits (see the docs).

I've created a work around in PR #1

m1ome commented 7 years ago

Closed by your PR, thank you! Awesome job!