0% found this document useful (0 votes)
4 views5 pages

C DataTypes Reference

The document provides a comprehensive overview of data types in C programming, detailing their definitions, sizes across 16-bit, 32-bit, and 64-bit systems, and their appropriate usage. It categorizes data types into integer types and floating-point types, explaining the characteristics and ranges of each type. Additionally, it emphasizes the importance of using the sizeof() operator to check actual sizes on different platforms.

Uploaded by

nonen0886
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

C DataTypes Reference

The document provides a comprehensive overview of data types in C programming, detailing their definitions, sizes across 16-bit, 32-bit, and 64-bit systems, and their appropriate usage. It categorizes data types into integer types and floating-point types, explaining the characteristics and ranges of each type. Additionally, it emphasizes the importance of using the sizeof() operator to check actual sizes on different platforms.

Uploaded by

nonen0886
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

C Programming — Data Types

Complete Reference: 16-bit | 32-bit | 64-bit Systems

1. What is a Data Type?


A data type tells the compiler: (1) what kind of data will be stored, (2) how much memory to reserve, and (3) what operations are allowed on that data.
Every variable in C must have a data type declared before it is used.

1.1 — Complete Size Reference (16-bit / 32-bit / 64-bit)


Cells highlighted in yellow indicate sizes that differ across platforms.

Data Type Definition 16-bit 32-bit 64-bit Forma


t
char Stores a single character or 1 byte 1 byte 1 byte %c /
small integer. 1 byte always. %d

unsigned Stores only positive 1 byte 1 byte 1 byte %c /


char characters/numbers (0 to %u
255). No negative values.

short Small whole number. Saves 2 bytes 2 bytes 2 bytes %hd


memory when values are
small (like age, month).

unsigned Short integer but only 2 bytes 2 bytes 2 bytes %hu


short positive (0 to 65,535). No
negatives.

int Most used type. Stores 2 bytes 4 bytes 4 bytes %d


whole numbers like roll no.,
marks, count.

unsigned Positive whole numbers only. 2 bytes 4 bytes 4 bytes %u


int Doubles the positive range of
int.

long Bigger whole numbers. Used 4 bytes 4 bytes 8 bytes %ld


Data Type Definition 16-bit 32-bit 64-bit Forma
t
for population, distances,
large counts.

unsigned Positive-only version of long. 4 bytes 4 bytes 8 bytes %lu


long Extends positive range
significantly.

long long Very large whole numbers. 8 bytes 8 bytes 8 bytes %lld
Used in banking, astronomy,
file sizes.

unsigned Largest integer type. Only 8 bytes 8 bytes 8 bytes %llu


long long positive. Used for memory
addresses, huge IDs.

float Decimal numbers with up to 4 bytes 4 bytes 4 bytes %f


6-7 significant digits. Good
for temperature, price.

double Decimal with up to 15-16 8 bytes 8 bytes 8 bytes %lf


significant digits. More
precise than float.

long Highest precision decimal. 10 12 16 %Lf


double 18-19 digits. Used in bytes bytes bytes
scientific computing.

📌 Yellow cells = size differs by platform/OS. Always use sizeof() to check actual size at runtime.
📌 On most modern 64-bit systems (Linux/Windows/macOS): int = 4 bytes, long = 8 bytes on Linux/macOS but 4 bytes on Windows 64-bit.

2. Integer Types — Definitions


Integer types store whole numbers (no decimal point). They can be signed (positive and negative) or unsigned (positive only).

char — Character Type


Size: Always 1 byte (8 bits) on ALL systems. Stores one character like 'A', 'z', '5', or '@'. Can also store very small integers (-128 to 127). Used in arrays to
form strings.
short — Short Integer
Size: Always 2 bytes. Stores small whole numbers. Useful when memory is limited and values fit within -32,768 to 32,767. Common in embedded systems
and microcontrollers.

int — Standard Integer


Size: 2 bytes on 16-bit systems, 4 bytes on 32-bit and 64-bit systems. The most commonly used integer type. Use for everyday counting, marks, scores,
and general-purpose numbers.

long — Long Integer


Size: 4 bytes on 16-bit and 32-bit systems, but 8 bytes on 64-bit Linux/macOS (still 4 bytes on 64-bit Windows). Use for larger numbers like population
counts or timestamps.

long long — Extended Integer


Size: Always 8 bytes on ALL modern systems (16/32/64-bit). The largest standard integer type. Use for very large numbers like bank balances, file sizes,
or astronomical distances.

3. Floating-Point Types — Definitions


Floating-point types store decimal numbers. They sacrifice some precision for the ability to represent fractions and very large/small values.

float — Single Precision


Size: Always 4 bytes. Provides 6-7 significant decimal digits of precision. Suitable for basic decimal calculations like temperature, price, or percentage
where exact precision is not critical.

double — Double Precision


Size: Always 8 bytes. Provides 15-16 significant digits. This is the default for decimal calculations in C. Always prefer double over float unless memory is a
constraint.

long double — Extended Precision


Size: 10 bytes (80-bit) on x86, 12 or 16 bytes on different compilers. Provides 18-19 significant digits. Used in scientific and engineering applications
where highest precision is needed.
4. Value Ranges at a Glance
Data Type Signed Range Unsigned Range Use When...
char -128 to 127 0 to 255 Storing
letters/symbols

short -32,768 to 32,767 0 to 65,535 Small numbers


like age

int (32-bit) -2,147,483,648 to 0 to 4,294,967,295 General purpose


2,147,483,647 numbers

long (64-bit) -9.2 × 10¹⁸ to 9.2 × 10¹⁸ 0 to 18.4 × 10¹⁸ Large values like
file sizes

float ±3.4 × 10⁻³⁸ to ±3.4 × N/A Decimals (less


10³⁸ precision)

double ±1.7 × 10⁻³⁰⁸ to ±1.7 × N/A Decimals (high


10³⁰⁸ precision)

5. Quick Decision Guide — Which Type to Use?


You Need... Use This Type Example
A single letter or symbol char 'A', 'z', '@'

A small whole number int age = 20, marks = 95

A very large number long long fileSize = 9000000000

A decimal number double pi = 3.14159265

Memory-efficient decimal float temp = 36.5f

Only positive counts unsigned int items = 4000000000

6. How to Check Size on Your System


Since sizes can vary by platform, always use the sizeof() operator to get the actual size on your machine:
printf("int = %zu bytes\n", sizeof(int));
printf("double = %zu bytes\n", sizeof(double));
📌 sizeof() returns type size_t, so always use %zu format specifier, not %d.
C Data Types Reference • For Educational Use • All sizes verified per C11 Standard

You might also like