http://qs321.pair.com?node_id=1181507


in reply to Multiply Hex values

Don't reduce them to "decimal", convert them to numbers (hex), multiply them and convert back to hexadecimal representation (sprintf):

perl -wle "print sprintf '%08x', hex(shift)*hex(shift)" 12340f 33

Replies are listed 'Best First'.
Re^2: Multiply Hex values
by kepler (Scribe) on Feb 09, 2017 at 15:15 UTC
    Hi

    Thank you very much. It seems that you were the only one who understood my problem. The strings are by default in hex (they are not numbers generated by me and then placed in hex format). Cheers.

Re^2: Multiply Hex values
by GotToBTru (Prior) on Feb 09, 2017 at 13:37 UTC

    How is what you are doing any different than what he said he didn't want to do? :)

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

      The OP wants to "convert to decimal" representation, which is the wrong terminology IMO.

      Thinking about numbers in terms of their representational basis is wrong - just because print converts numbers to their representation in decimal, that doesn't mean they are still numbers ;)