in reply to Math after hex conversion

The only math I see is $count_xor += 1. But the error message has nothing to do with math. You don't show which modules you're using, but you've forgotten the one that defines is_odd().

But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)