Jumat, 20 Mei 2011

DATA TYPE IN PASCAL

Consider the following simple program listings:
 program data_type;
uses wincrt;
var a:integer;
b:real;
c:string;
d:boolean;
e:array[1..100] of integer;
begin
a:= 100;
b:= 100.1;
c:= ’PASCAL’;
d:= TRUE;
end.

In the declaration contained var identifier identifier-namely a, b, c, d and e. After
writing identifier, identifier types are written with a colon separated
(colon). The above types include integer, real, string, boolean and array.
The type is a trait or characteristic that serves to limit the value or range
of an identifier. Type is divided into 9 (nine) types, including: arrays,
file, object, ordinal, pointer, real, record, sets and strings.
In the structure of the pascal, which typically uses the following types of identifier
is the const, type, var, procedures and functions. This section will discuss
first use of the type in variable declarations. And the type discussed in this section
is the ordinal types, real and string.
Variable is an identifier that represents a value with its type included
and declared in the var. So, in the example code above, the identifier of a, b, c, d
and e is a variable.

1. ORDINAL TYPE
Ordinal type is a numeric type that is worth a round number negative or
positive. According to the coverage value, ordinal type is divided into 7 (seven) types:
Type Range / Range Size
Byte 0 .. 255 8 bit
Integer -32768 .. 32767 16 bit
Word 0 .. 65535 16 bit
Longint -2147483648 .. 2147483647 32 bit
Boolean TRUE .. FALSE 8 bit
Chr ASCII 8 bit
Especially for type boolean and chr, this type is the type ordinal or predefine
is undefined. So chr and boolean type can be considered not ordinal because
can be used in numerical operations. While the ordinal type except boolean and chr
commonly referred to type integer
If the value assigned to the variable does not match the type of coverage
variable, it will cause an error. 

2. REAL TYPE
Real type is a numeric type that include real numbers, both numbers
round or fractions. Characteristics that distinguish the ordinal type is that type of real
always has a value behind the comma, either round or denomination. Therefore
writing of output values
​​using the notation floating-point or exponential.
Consider the example of writing a value of type real following:
Real Numbers Real Writing On Type
25 2.5000000000E+01
10.5 1.0500000000E+01
0.0015 1.5000000000E-03
0.0705 7.0500000000E-02
2500.017009 2.5000170090E+03
In the writing of fractions contained a comma. In Pascal this sign is not
use a comma rather ordinary wear periods. Real type is divided into
5 (five) according to its scope, namely:
Type Range / Range Size 
Real 2.9e-39..1.7e38 6 bit
Single 1.5e-45..3.4e38 4 bit
Double 5.0e-324..1.7e308 8 bit
Extended 3.4e-4932..1.1e4932 10 bit
Comp -9.2e18..9.2e18 8 bit

3. STRING TYPE
The type string is a type variable in the form of a series of characters that are
text. The maximum length of characters in a type of string is 255 characters. The hallmark of a
value of type string is the use of single quotation marks (aphostrope) which
given at the beginning and at the end of the string. 





 


Tidak ada komentar:

Posting Komentar