Hex and BCD (end of article)

Source: Internet
Author: User
Hexadecimal to BCD code good Understanding, the problem is the BCD code to hexadecimal number;

HEX2BCD:
What is the BCD code for 0x3f? Correct answer: 99, or 0x63
0x3f=63, add 0x,->0x63, and then turn 0x63 into a (0x63=99)
1, if it is to be represented as 16 binary, then convert to 10 binary number, preceded by 0x symbol; (hexadecimal representation)

2, if you want to represent a decimal, then first converted to 10, preceded by a 0x symbol, and then add the symbol
hexadecimal number to decimal number; (decimal notation)

If a number is 0x38, the BCD code is 86


Bcd2hex: (Note:)
1, if the number is 16 decimal notation, the 0x symbol is removed, as 10 binary number is converted directly to 16 binary number;
(provided that any one of the 16 binary representation numbers cannot be greater than 9, i.e. a, B, C, D, E, F)
such as: 0x999, remove 0x,->999, and then to hexadecimal number of 0x3e7
2, if this number is expressed in decimal, first convert this number to 16, then remove the 0x symbol, as
Decimal number, then converted to hexadecimal number, (note: This number must be within a certain range, before the line, such as 999 converted to
Hex is 0x3e7, 0x is removed, 3E7 is not in the 10 binary representation range,)

Above is the number within a certain range, for the number not within a certain range how to turn. It was really hard to understand at first,
Because the mathematical rules that the school teaches us limit our thinking, how do we understand a number 3E7 as a 10?
or by decimal, bit, 10, hundred ..., but now the number on the ten is 14,

What is the conversion of BCD code 999 to 16 binary? Correct answer: 447, if the person 0x1bf, why. I can't think of ...
Conversion process:
999 to Hex,->0x3e7,
3
3*10+e=44
(3*10+e) *10+7
=447
It is equivalent to 0x3e7 as 10 into the understanding, then is 3*100+e*10+7, simple not.


Note: A hexadecimal number is converted to BCD code, but this BCD code is then converted to hexadecimal number, not equal to this number;
Example: If a number is 0X999,HEX2BCD (0x999) =0x2547 (9543), Bcd2hex (0x2547) =0x9f3 (2547)

And the number of a BCD code can be converted to hexadecimal number, this hexadecimal number can be reversed to the BCD code, may be equal to this
Number (this number is hexadecimal, and each digit is between 0~9), or it may not be equal to this number;
such as: Bcd2hex (0x999) =0x3e7 (999), HEX2BCD (0x3e7) =2457 (0x999) (equals)
Bcd2hex (0X9F3) =0x41d (1053), HEX2BCD (0x41d) =0x1053 (4179)
Bcd2hex (999) =0X1BF (447), HEX2BCD (0X1BF) =0x447 (1095) (not equal to)

Bcd2hex (0x447) =0X1BF (447), HEX2BCD (0X1BF) =0x447 (1095) (equals)

Conclusion: 16 binary BCD is irreversible, and BCD to 16 is reversible.

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.