Binary to integer (no parsing)

Try :binary.decode_unsigned/1,2, it does exactly what your code does…