Home > Back-end >  C int
C int

Time:10-05

Ask next bosses will output is what the inside of the int - 1, 65535; But in short int will output 1

CodePudding user response:

Int has the sign bit
Unsigned int unsigned number

CodePudding user response:

reference 1st floor gouyanfen response:
int has the sign bit
Unsigned int unsigned number

But the int (1) output is 62235

CodePudding user response:

reference 1st floor gouyanfen response:
int has the sign bit
Unsigned int unsigned number

For bosses to help analyze the two figure

CodePudding user response:

The first thing you see how negative in memory is the binary representation of the, 1=62235 this is pulled eggs, you are likely to appear this kind of situation, probably because you defined is short int, you first have to understand all kinds of memory points and length,

CodePudding user response:

reference 4 floor gouyanfen response:
the first thing you see how negative in memory is the binary representation of the, 1=62235 this is pulled eggs, you are likely to appear this kind of situation, probably because you defined is short int, you first have to understand all kinds of memory points and length,

Well, the crab crab crab crab crab crab

CodePudding user response:

Figure 1 m=1 is the return value (unsigned short) 65535, so in the type to int value is 65535, figure 2 short int is not short, in the same type unsigned and signed assignment, is a direct copy short the two bytes of memory, unsigned short of the 65535-1 with short memory is the same, is FFFF, just didn't look at the sign bit when reading leads to the difference between a value of 1, 65535,

CodePudding user response:

refer to 6th floor Mrxlin response:
figure 1 m=1 is the return value (unsigned short) 65535, so in the type to int value is 65535, figure 2 short int is not short, in the same type unsigned and signed the assignment, the two bytes of memory is copied short, unsigned short of the 65535-1 with short memory is the same, is FFFF, just didn't look at the sign bit difference when reading leads to a value of 1, 65535,

Understand the crab crab crab crab??

CodePudding user response:

Crossing the line??