Convert HEX to DEC in your head

 

Just a reminder for myself how to convert HEX to DEC and maybe backwards in my head.


The original article is from stackoverflow, you can find it here though: http://stackoverflow.com/questions/910309/how-to-turn-hexadecimal-into-decimal-using-brain

 

So here it goes:

 

this is the equation I'm using in my head 

0x15 = 5+(1*16) = 21

For the oposite I just do educated guess in my head

21, that means 16 goes in once so 0x1_

21-16 = 5 so 0x15

 

How about 4 byte HEX number?

Like this:

0xAB89

0xAB = 11+(10*16) = 171

171*256 = 43776

0x89 = 9+(8*16) = 137

43776+137 = 43913

 

How about 4 byte DEC to HEX?


38908

 

38908/256 = 151

151/16 = 9 = 0x9_

151%16 = 7 so upper bytes = 0x97

 

38908%256 = 252

252/16 = 15  = 0xF_

252%16 = 12 = 0xFC
 

 

So 38908 = 0x97FC




ADVERTISEMENT

  • Proact IMS

    Proact IMS in Touch gesture recognition using body capacitance

    Single‑electrode detection and differentiating gestures like pinch, grab, or multi‑finger touch by how much skin contacts the electrode is a clever design.Explore cutting-edge services and products at https://www.proact-ims.com/ or contact us at +91 80 3542 9949 for collaboration and...

    Proact IMS

    Proact IMS in Touch gesture recognition using body capacitance

    Single‑electrode detection and differentiating gestures like pinch, grab, or multi‑finger touch by how much skin contacts the electrode is a clever design.Explore cutting-edge services and products at https://www.proact-ims.com/ or contact us at +91 80 3542 9949 for collaboration and...

    Proact IMS

    Proact IMS in Strain Gauge based weight sensor (load cell)

    Clear explanation of principles (strain, Wheatstone bridge, gauge factor) — especially helpful for beginners..Explore cutting-edge services and products at https://www.proact-ims.com/ or contact us at +91 80 3542 9949 for collaboration and innovation opportunities. Elevate your...

    Proact IMS

    Proact IMS in Strain Gauge based weight sensor (load cell)

    Clear explanation of principles (strain, Wheatstone bridge, gauge factor) — especially helpful for beginners..Explore cutting-edge services and products at https://www.proact-ims.com/ or contact us at +91 80 3542 9949 for collaboration and innovation opportunities. Elevate your...

    Proact IMS

    Proact IMS in Strain Gauge based weight sensor (load cell)

    Clear explanation of principles (strain, Wheatstone bridge, gauge factor) — especially helpful for beginners..Explore cutting-edge services and products at https://www.proact-ims.com/ or contact us at +91 80 3542 9949 for collaboration and innovation opportunities. Elevate your...

    proactims

    proactims in Strain Gauge based weight sensor (load cell)

    This guide made the transition from basic principles to advanced applications smooth—it feels like a complete learning path for anyone new to...

    proactims

    proactims in Strain Gauge based weight sensor (load cell)

    This guide made the transition from basic principles to advanced applications smooth—it feels like a complete learning path for anyone new to...