Topic 7 - Basic Types Flashcards
The leftmost bit of a SIGNED integer is:
0 if number is positive or zero
1 if number is negative
The largest 16-bit signed integer is:
2^15 - 1
The largest 32-bit signed integer is:
2^31 - 1
An integer with no sign bit is said to be:
unsigned
largest 16 bit unsigned integer is:
2^16 - 1
largest 32 bit unsigned integer is:
2^32 - 1
By default, what type of integers are integer variables?
Signed integers.
How many bits is the int type usually?
32 bits
How do you tell the compiler that a variable has no sign bit?
declare it as unsigned.
Decimal constants contain digits between___ and
must / must not begin with___
0 and 9
must not begin with a zero
Octal constants contain digits between___ and
must / must not begin with___
0 and 7
must begin with a zero
Hexadecimal constants contain digits between___ and
letters between a and f must begin with ___
0 and 9 0x or 0X: 0xf 0xff 0X7fff
The letters in a hexadecimal constant may be _____
either upper or lower case
How do you force the compiler to treat a constant as a long integer?
with the letter L or l:
15L
0x7fffL
How do you force the compiler to treat a constant as an unsigned integer?
follow it with the letter U or u:
15U
0x7fffU
What is the term that describes the event where arithmetic operations performed on integers results in a number too large to be represented as an int( because it requires too many bits)?
Overflow
How do you read or write an unsigned decimal integer? (ie. when using scanf or printf)?
Use the letter “u” instead of “d” as a conversion specifier.
How do you read or write an unsigned octal integer? (ie. when using scanf or printf)?
“o” instead of “d”
How do you read or write an unsigned hexadecimal integer? (ie. when using scanf or printf)?
“x” instead of “d”
How do you read or write a short integer? (ie. when using scanf or printf)?
“h” in front of d, u, o, x in the conversion specification:
scanf(“%hd”, &i);