Binary coded decimal (BCD) to Hexadecimal conversion

前端 未结 5 1569
攒了一身酷
攒了一身酷 2021-01-12 02:47

can someone explain to me how to convert BCD to Hexadecimal? For example how can i convert 98(BCD) to Hexadecimal. Thanks.

5条回答
  •  孤城傲影
    2021-01-12 02:59

    Go between different combinations of Hex, Decimal, and Binary. If you know how binary works then you should easily be able to use BCD:

    Hex  Dec  BCD
    0    0    0000
    1    1    0001
    2    2    0010
    3    3    0011
    4    4    0100
    5    5    0101
    6    6    0110
    7    7    0111
    8    8    1000
    9    9    1001
    A   10    0001 0000 <-- notice that each digit looks like hex except it can only go to 9.
    B   11    0001 0001
    C   12    0001 0010
    D   13    0001 0011
    E   14    0001 0100
    F   15    0001 0101
    

    Once you got this part of it down, you should be able to use divide by 10 or %10 to find any combination to generate your BCD. Since it only uses 10 combinations instead of all 16 you will lose some information.

提交回复
热议问题