HQ-hexadecimal conversion

Source: Internet
Author: User

(二进制,八进制,十进制,十六进制)

  二进制  是由 0和1 组成

【十进制转二进制】    如   23写成二进制为 10111

    23/2=11余1

    11/2=5    1

    5/2=2     1

    2/2=1     0

  所以为  23写成二进制为10111

【二进制转十进制公式】

      a*2^0+b*2^1+……+m*2^(n-1)=

      例如 1011写成十进制为 1*2^0+1*2^1+0*2^2+1*2^3=11

重点:1.写二进制转十进制时要从右往左写

      2.指数从0开始

【十进制转八进制】

    例如  48的八进制

        48/8=6 余0

      所以 48的八进制为60

 

【八进制转十进制】   (同二进制转十进制)

      a*8^0+b*8^1+……+m*8^(n-1)=

     60的十进制为     0*8^0+6*8^1=48

 

十六进制数为:0,1,2,3,4,5,6,7,8,9,A(10),B(11),C(12),D(13),E(14),F(15)

【十进制转十六进制】:如45十六进制为2D

【十六进制转十进制】:a*16^0+b*16^1+……+m*16^(n-1)=

 

 【二进制转八进制】 ( 二进制从左往右,每三位一组,每组从右开始第一位为1,第二位为2,第二位4,分别于二进制数相乘,每组求和,最后得数左右互换位置。){为什么三个一组,因为 2的三次方为8。(1,2,4)}

       如   10110101

              10   110   101

          0*1+1*2=2    0*1+1*2+1*4=6    1*1+0*2+1*4=5

        所以10110101的八进制为562

 

【八进制转二进制】(每个数分别除以2,每组得数不够三位的从左面添0补充,顺序从左到右顺着写即可)

         如   72的二进制为     111010

 

【二进制转十六进制】

      同上,从左往右每四个数为一组,相乘的数为(1,2,4,8)   

 

【十六进制转二进制 】

      同上,但要注意(ABCDEF),每一个字母为一组不能拆开除以2,最后结果从左往右顺着写。

hq—进制转换

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.