{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# L7 - 7 BASIC TYPES Systems of numeration Numeric Types Cs...

This preview shows pages 1–13. Sign up to view the full content.

7. BASIC TYPES

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Systems of numeration
Numeric Types C’s basic types include integer types and floating types. Integer types can be either signed or unsigned. A value of a signed type can be either negative, zero, or positive. A value of an unsigned type must be zero or positive.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Integer Types C provides six integer types: C99 also supports the long long int type, whose values typically range from –2 63 to 2 63 – 1, and unsigned long long int, whose values typically range from 0 to 2 64 – 1.
Integer Types Integer types can be abbreviated by omitting the word int: long i; /* same as long int i; */ In general, avoid using unsigned types. <limits.h> INT_MIN INT_MAX

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Integer Constants Integer constants may be written in decimal (base 10), octal (base 8), or hexadecimal (base 16). Decimal integer constants contain digits, but must not begin with a zero: 15 255 32767 Octal integer constants contain only digits between 0 and 7, and must begin with a zero: 017 0377 077777
Integer Constants Hexadecimal integer constants contain digits between 0 and 9 and letters between A and F (or a and f), and always begin with 0x: 0xf 0xff 0x7fff The letters in a hexadecimal constant may be either upper or lower case. Force type 15L 0377L 0x7fffL 15U 0377U 0x7fffU 0xffffffffUL

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Integer Overflow Signed Unsigned
Reading and Writing Integers When reading or writing an unsigned integer, use the letter u (decimal), o (octal), or x (hex) in the conversion specification: unsigned int u; printf("%u", u); /* writes u in base 10 */ printf("%o", u); /* writes u in base 8 */ printf("%x", u); /* writes u in base 16 */ When reading or writing a short integer, put the letter h in front of d, o, x, or u: short int s; printf("%hd", s);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Reading and Writing Integers When reading or writing a long integer, put the letter l in front of d, o, x, or u: long int l; printf("%ld", l);
Floating Types C supports three floating types: (Ranges shown are typical.)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Floating Constants Floating constants can be written in either fixed-point notation or scientific notation.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 33

L7 - 7 BASIC TYPES Systems of numeration Numeric Types Cs...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online