Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

ICT

• +/ -
79,228,162,514,264,337,593,543,950,335
with no decimal point
Data Types, Variables & Constant • +/-7.9228162514264337593543950335
with 28 decimal places to the right.
2nd Quarter
• The smallest non-zero value accepted is +/-
0.0000000000000000000000000001. (27
zeroes on decimal)
Data Type – e. Single –
• It is the type of the data being processed in the Accepted ranges are:
program. • -3.402823E38 to -1.491298E-45 for negative
• A classification of data that determines the values it values
may contain, plus the operations that may be • 1.401298-45 to 3.492823E38 for positive
performed on it, and tells the compiler or interpreter values.
on how the programmer intends to use the data.
f. Double –
CLASSIFICATION OF DATA TYPES The accepted range of values are:
• -1.79769313486231E308 to -
a. Numeric Data – 4.94065645841247E-324 for negative
Can be used to perform mathematical operations values.
b. Non-numeric data – • 4.94065645841247E-324 to
Data that can’t be manipulated by arithmetic 1.79769313486231E308 for positive values.
operators. g. Currency –
• Useful for monetary calculations.
NUMERIC DATA • Can store both positive and negative values.
a. Byte – • Can store 15 digits to the left of the decimal
and 4 digits to the right.
• This type of data requires one byte of
memory. • Allowed range is -
922,337,203,684,477.5808 to
• Variables that are Byte type can store values
922,377,203,658,477.5907.
form 0 – 255.
• 0 Default Value. Negative or values greater NON-NUMERIC DATA
than 255 are not allowed.
• Attempting to assign invalid values will a. Boolean –
result to an overflow error. • Requires two bytes of memory and can
b. Integer/Short Integer – store only two values – TRUE and FALSE
• Data types that are used to store the whole (alternatively 1 or 0 respectively).
integer value. • The default value of a Boolean variable is
• This occupies 2 bytes of memory. false.
• Can accept both positive values and b. Date –
negative values. • Use to represent the date and time.
• Used frequently as it is more reliable. • Date range values from Jan 1, 0100 to
c. Long – December 31, 9999.
• Alternative to an integer data type which • Time values from 0:00:00 to 23:59:59 and
also stores a whole integer value. occupies 8 bytes of storage size.
• Occupies 4 bytes (2 more byte compared to c. String –
integer). • Used to store string values.
• It has a range of values from -2,147,483,648 • String defined as a sequence of characters
to 2,147,483,648 (words, e.g: “hello word”, “dog”, etc.)
d. Decimal –
• Exact numeric data type that is used for its
precision.
• This type contains the below range of
values.
– Variable-length String – Occupies 7. Lessen the number of the characters of the
10 bytes of storage size plus the name of the variable. The shorter the variable
memory required for the string name, the more efficient the program. Variable
that is the string length. They have names can’t exceed 256 characters in length.
range value form 0 to
8. In most cases, uppercase and lowercase letters
approximately 20 billion
are read differently. “A” and “a” may hold
– Fixed-length String –
– Occupies the memory equal to the different data.
length of the string itself. It can 9. Variable names must not be a reserved word.
range from 1 to approximately Generally, you shouldn’t use any names that are
65,400 characters. the same as the function, statement, method,
d. Object – and intrinsic constant names used in any host
• Any reference (used for pictures and application.
images)
e. Variant – Examples of using variables (Python):
• Universal data type.
• Can accept any kind of data numeric and (console command)
non-numeric.
• Variant data gives more flexibility while
working with data.
• Uses more storage size than any other data
type.
• Default data type is variant variable (if data
type not mentioned).

VARIABLES
Variables –
Primary storage location that can store different numeric or
alphanumeric values. It is also a memory space allocated by a
computer user for processing and storing data.

• Named area in the memory, holds temporary data.


• A program can handle many data.
• Allocates a portion of the memory depending on the
kind of data.

A program should consider the following in allocating (output result)


memory –

• How much space will the data consume?


• Where in the memory was each variable stored?

RULES IN NAMING VARIABLE


1. It must begin with a letter or an alphabet, may
be follow by combinations of alphanumeric
characters.
2. No special characters like @, &, $, #, and period
(.).
3. It must be unique; names can’t be repeated.
4. Should indicative of the value it holds.
5. Avoid using confusing letters and numbers such
as “0” (zero) and letter “o”.
6. Use underscore in replacement of space.
CONSTANT
Constant –
Values that do not change during the execution of the
program

Examples:

Pi = 3.1416

A = 50

You might also like