C Numeric Integer Floating-point Variable Types Small Large integers floating-point values character Short Long integer Unsigned short long integer single Long double floating-point C provides several different types of numeric variables because different numeric values have varying memory storage requirements

Files Recovery Software
Home Contact Details Customer Support Download Demo Products  

 
 

Numeric Variable Types

C provides several different types of numeric variables because different numeric values have varying memory storage requirements. These numeric types differ in the ease with which certain mathematical operations can be performed on them.

Small integers require less memory to store, and your computer can perform mathematical operations with such numbers very quickly. Large integers and floating-point values require more storage space and more time for mathematical operations. By using the appropriate variable types, you ensure that your program runs as efficiently as possible.

C's numeric variables fall into the following two main categories:

  • Integer variables
  • Floating-point variables

Within each of these categories are two or more specific variable types. Table given next, shows the amount of memory, in bytes, required to hold a single variable of each type.

The type char may be equivalent to either signed char or unsigned char, but it is always a separate type from either of these.

In C there is no difference between storing characters or their corresponding numerical values in a variable, so there is also no need for a function to convert between a character and its numerical value or vice versa. For the other integer types, if you omit signed or unsigned the default will be signed, so e.g. int and signed int are equivalent.

The type int must be greater than or equal to the type short, and smaller than or equal to the type long. If you simply need to store some values which are not enormously large it's often a good idea to use the type int; it usually is the size the processor can deal with the easiest, and therefore the fastest.

With several compilers double and long double are equivalent. That combined with the fact that most standard mathematical functions work with type double, is a good reason to always use the type double if you have to work with fractional numbers.

The following table is to better describe the variable types:

Variable Type

Keyword

Bytes Required

Range

Format

Character

char

1

-128 to 127

%c

Integer

int

2

-32768 to 32767

%d

Short integer

short

2

-32768 to 32767

%d

Long integer

long

4

-2,147,483,648 to 2,147,438,647

%ld

Unsigned character

unsigned char

1

0 to 255

%c

Unsigned integer

unsigned int

2

0 to 65535

%u

Unsigned short integer

unsigned short

2

0 to 65535

%u

Unsigned long integer

unsigned long

4

0 to 4,294,967,295

%lu

Single floating-point

float

4

-3.4E38 to 3.4E38

%f

Double floating-point

double

8

-1.7E308 to 1.7E308

%lf

Long double floating-point

long double

10

-1.7E4932 to 1.7E4932

%Lf


Previous page

page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20

 
 

page 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37

 
 

page 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54

 
 

page 55 | 56 | 57 | 58 | 59 | 60

Next page
 
 
Data Recovery Book
 
Chapter 1 An Overview of Data Recovery
Chapter 2 Introduction of Hard Disks
Chapter 3 Logical Approach to Disks and OS
Chapter 4 Number Systems
Chapter 5 Introduction of C Programming
Chapter 6 Introduction to Computer Basics
Chapter 7 Necessary DOS Commands
Chapter 8 Disk-BIOS Functions and Interrupts Handling With C
Chapter 9 Handling Large Hard Disks
Chapter 10 Data Recovery From Corrupted Floppy
Chapter 11 Making Backups
Chapter 12 Reading and Modifying MBR with Programming
Chapter 13 Reading and Modifying DBR with Programming
Chapter 14 Programming for “Raw File” Recovery
Chapter 15 Programming for Data Wipers
Chapter 16 Developing more Utilities for Disks
Appendix Glossary of Data Recovery Terms
 
 
Pro Data Doctor

Home

Products

Contact Details

Customer Support

Download Demo

Terms and Conditions

 
Pro Data Doctor