"Song Hongkang program thought learning Diary 2" logic and implementation binary conversion to hexadecimal operation

Source: Internet
Author: User

/**
Binary conversion binary 60 to Hex

*/
Class WeiExercise2
{
public static void Main (string[] args)
{
int i=60;//0011 1100

int b=i&15;//&15:0000 1111= (0000 1100=12=b)
int c=b-10;
int d= (c>10)? c+ ' a ': c;//d=b-10+ ' a ' = = ' C '. Get C
String k1= (b<=9) b + "":(char) (b-10+ ' a ') + "";

i=i>>4;//i=0000 0011
int b2=i&15;
String k2= (b2<=9) b2+ "":(char) (b2-10+ ' a ') + "";

System.out.print ("Hex of 60" is "+K2+K1");


}
}

"Song Hongkang program thought learning Diary 2" logic and implementation binary conversion to hexadecimal operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.