in reply to Math after hex conversion

Why do you convert your number to a string in hexadecimal representation when you still want to do arithmetic with it?

I think that removing the line will do what you want:

# $b_ecc = $b_ecc->as_hex(); # remove this