2013年9月4日星期三

For integer conversion between hexadecimal

Finishing java notes today , I saw about hex conversion problems , a look almost forgotten , and quickly they find a bit of computer composition principle , I remember when the teacher is talking often said that as a computer, be sure to with numbers , but also to convert between hexadecimal Shoudaoqinlai ah , hehe. Today, rearrange , written down , we are interested can look at the wrong place can be pointed out , ah, may not be comprehensive, the rest on to people.


(1) binary, octal , hexadecimal conversion to decimal :
binary : 2 (a): a representative of power ;
1011 = 1 * 2 (3) +0 * 2 (2) +1 * 2 (1) +1 * 2 (0);
hex : BA = 11 * 16 (1) +10 * 16 (0);
Octal : 23 = 2 * 8 ( 1 ) 3 * 8 ( 0 ) ;
(2) binary into octal :

example: 10110110 ( 2 ) = 266 ( 8 ) Take one every three front inadequate compensation 0 ;

(3) Binary to hexadecimal :
eg : 1011 0110 (2) = B16 (16) every four to take a front inadequate compensation 0 ;

(4) decimal to binary : 2 (m): m represents power ;
2 (0) = 1 2 (1) = 2 2 ( 2 ) = 4
2 (3) = 8 2 (4) = 16 2 ( 5 ) = 32
2 (6) = 64 2 (7) = 128 2 ( 8 ) = 256
2 (9) = 512 2 (10) = 1024 2 ( 11 ) = 2048
such as : 567 ( 10 ) = 512 +32 +16 +4 +2 +1 = 1000110111 ( 2 )

(5) into decimal octal : 8 (n): n represents power ;
8 (0) = 1 8 (1) = 8 8 ( 2 ) = 64
8 (3) = 512 8 (4) = 4096
eg : 85 ( 10 ) = 64 + 2 * 8 ( 1 ) + 5 * 8 ( 0 ) ;

(6) decimal to hexadecimal :
16 (0) = 1 16 (1) = 16 16 ( 2 ) = 256
16 (3) = 4096
eg : 85 ( 10 ) = 5 * 16 ( 1 ) + 5 * 16 ( 0 ) = 55 ( 16 )
(7) octal and hexadecimal conversion between decimal by an intermediate variable to represent ;

Please rest unsaid for instance , there is the octal and hexadecimal direct conversion between , I will not , I hope we can give pointers pointing ah ! ( Originally the above there are several windows of the drawing where I finished , but I do not know why , I'm not here will upload pictures of this , everyone laughed ) .
------ Solution ---------------------------------------- ----
the Old, good good.
Decimal to any band, just know that in addition to the short , take I can.
------ For reference only -------------------------------------- -


say well !
------ For reference only -------------------------------------- -

forget Results posted , this memory , alas !

没有评论:

发表评论