2_Objective-C Data Types

Data types refer to an extensive system used for declaring different data types

The type determines how much space it occupies in storage and how the bit pattern stored is interpreted.

Data type classifieds

  • Basic Types : They are arithmetic types
  • Enumerated types : They are again arithmetic types
  • The type void :┬áThe type specifier void indicates that no value is available.
  • Derived types : Other types of data

Basic types

  • (a) integer types
  • (b) floating-point types.

The integer types

Type Storage size Value range
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 4 bytes -2,147,483,648 to 2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295

Floating-Point Types

Type Storage size Value range Precision
float 4 byte 1.2E-38 to 3.4E+38 6 decimal places
double 8 byte 2.3E-308 to 1.7E+308 15 decimal places
long double 10 byte 3.4E-4932 to 1.1E+4932 19 decimal places

Enumerated Types

They are used to define variables that can only be assigned certain discrete integer values throughout the program.

Note : A variable is name given to a storage area that our programs can manipulate.

Note : Later we will study about Variables

Void Type

The void type specifies that no value is available. It is used in three kinds of situations:

  • Function returns as void
  • Function arguments as void

You will know more about void when you study function

Note : A function is a group of statements that together perform a task.

Note : Later we will study more about Functions

Derived types

  • Pointer : Is a variable whose value is the address of another variable
  • Array : Collection of variables of the same type
  • Structure : Allows you to combine data items of different kinds.
  • Union : data construct that allow you to store more than 1 type of data in the same storage area.
  • Function : A function is a group of statements that together perform a task.

Note : The array and structure types are referred to collectively as the aggregate types

Note : Later we will study more about Derived type

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: