Decimal 2 Hexadecimal


E-mail this post



Remember me (?)



All personal information that you provide here will be governed by the Privacy Policy of Blogger.com. More...



Number we want to transform uses base X: we would like to transform this number into new one, that uses Y base. In this case we will use method of continuous dividing and multiplying (dividing numbers left of comma (,) with Y and multiplying numbers on the right side of comma, by Y - rational numbers). This method is best understood looking at these examples, where X equals 10 and Y equals 16 (hex base, B=16)


Decimal System:

Base: 10
Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9


Hexadecimal (hex) System:

Base: 16
Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Example: 27 (decimal) = 1B 16 (hex)





Decimal 2 Hex




Example

Transform 2540,34 (decimal) into hex number-result ~ 9EC, 570A316


a) left from”,

2540 : 16 = 158 , remaining 12 => C        160        last digit
158 : 16 = 9 , remaining 14 =>
E 161
9 : 16 = 0 , remaining 9 =>
9 162 first digit

end of procedure => 9EC 16


b) right from “,

0,34 * 16 = 5,44 5 => 5 16-1 first digit after zero
0,44 * 16 = 7,04 7 =>
7 16-2
0,04 * 16 = 0,64 0 => 0 16-3
0,64 * 16 = 10,24 10 => A 16-4
0,24 * 16 = 3,84 3 => 3 16-5


procedure could be continued => 0, 570A3… 16



Final result ~ 9EC , 570A316




Technorati Tags:
, , , , , , , , , , ,






1 Responses to “Decimal 2 Hexadecimal”

  1. Anonymous gg 

    chetta

Leave a Reply

      Convert to boldConvert to italicConvert to link

 


German Flag Spanish Flag French Flag Italian Flag Portuguese Flag Japanese Flag Korean Flag Chinese Flag British Flag


This Website is optimized for Firefox. Users browsing with Internet Explorer may encounter problems while viewing pages.


C++ Maniac



Learn C



Additional



#include



Learn Converting



Appendix


Links


Previous posts




Daily Lessons for programming in Visual Studio, using C code.