Data has their own type (Data Types)

BAB IV
Data Types
data type defines a collection of data objects and a set of predefined operations on those objects
descriptor is the collection of the attributes of a variable
An object represents an instance of a user-defined type (struct)
Primitive Data Types
Almost all programming languages provide a set of primitive data types. Primitive Data Types not defined in terms of other data types.
Some Primitive data types
·         Integer = can store integer in range 32 bit((2^31)-1), if signed(can be negative or positive), and ((2^32)-1) if unsigned, only positive integer.
·         Floating Point = can store real number
·         Complex
·         Decimal
·         Boolean = value only 0 or 1 (can’t be both at the same time).
·         Character = alphabet, number as character, symbol, etc.
Character String Types are sequences of characters. Operation for String data type are
Assignment and copying
Comparison (comparing the value of character in the sequence)
Catenation (string + another string)
Substring Reference (taking some part of the string, or even the whole string itself)
Pattern Matching.

String Length is kind of a problem because different language serves a different length or size for its own string data types (class).
Static : COBOL, Java String Class.
Limited Dynamic Length  : C and C++, and identifier of the string length is done by using a special character placed at the end of the string.
Dynamic (no Limit length) : SNOBOL4, Perl, JavaScript.
Ada supports all three string length options.
Array
Array is a homogeneous aggregate of data elements in which an individual element is identified by its position in the aggregate, relative to the first element.
Indexing is a mapping from indices of the element. Example :
In C++ or C :
Int tool[5]={2, 1, 4, 5, 3};
If we want to access tool number 1, we need to call tool[0], because the indexing start from 0 to n-1 (n is the size of the array);
Then when we called tool[0] it will give a value of 2, rather than 0, because 2 is the value in index 0 not 0.
There is some more data type other than we discussed above, some example :
          Tuple : A tuple is a data type that is similar to a record, except that the elements are not named
          union is a type whose variables are allowed to store different type values at different times during execution
          pointer type variable has a range of values that consists of memory addresses and a special value, nil.
          Long long integer (C++) (Signed or Unsigned 64 bit).


Setelah saya belajar bab ini, saya mengetahui beberapa hal yang diproses oleh komputer berbeda tergantung tipe data apa yang diproses.

Tidak ada komentar:

Posting Komentar