Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Multiply Hex values

by Corion (Pope)
on Feb 09, 2017 at 11:31 UTC ( #1181507=note: print w/replies, xml ) Need Help??


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 ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1181507]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2021-01-20 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?