Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Multiply Hex values

by Corion (Patriarch)
on Feb 09, 2017 at 11:31 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1181507]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-23 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found