Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - About the conversion of characters into integers, such as the difference between 0 and' 0'
About the conversion of characters into integers, such as the difference between 0 and' 0'
I think we can do it ... first of all, within the scope of ASCII code, let's make two definitions clear.

Characters: enclosed in single quotation marks, such as' a',' z',' 0',' g', etc.

Encoding: This is the position of the character in the ASCII table. It is a number. For example, the position of' a' is 0x4 1, which is also used in the operation.

So, now let's talk about your question:

0, this is a number.

0', this is a character, and the encoding is 0x30.

1. So in the case of character variables:

0-'0'=0xD0,0-0=0,' 0'-'0'=0

2.0 can be a numeric value of characters, integers or long integers.

3. I don't know what you mean, for example, you declare int k =123 in C language; When translating into machine code, the compiler must assign the variable k 123 or 0x7B (usually the unit in memory) (note that there is no decimal statement in memory). If you use the scanf function to assign a value of 567 to k, you are actually entering the characters' 5',' 6' and' 7' on the keyboard, but the program will help you convert and execute k = ('5'-0x30) *100+('6'-0x30) * 65430 through invisible codes and intermediate variables. This conversion process is completed by the program added by the compiler itself, so don't worry, even if you input floating-point numbers, it can be easily done-if you write this conversion process yourself, it is easy to make mistakes!

4.3 Answered.

When dealing with C language, don't worry about the numbers on the keyboard, but be careful when compiling, and the conversion process must be well written.

It is easy to convert the characters' 0'~'9' into numbers 0~9, because the codes of the characters' 0' ~' 9' are 0x30~0x39, so just clear the upper four digits.