## Wednesday 31 March 2021

### Primitive Data Types | PPL | Sebesta | Elementary Data Types in Programming Language

In this post, we will see Primitive Data Types | PPL | Sebesta | Elementary Data Types in Programming Language | primitive data types, data types in ppl, data types ppl, elementary data types in programming language, ppl, sebesta, introduction

2. Primitive data Types

Data types that are not defined in terms of other types are called primitive data types.

Also called as Built-in data types.

Examples:

a. Numeric Data Types (Integer, Floating-Point, Complex, Decimal etc.)

b. Boolean Data Types

C. Character Data Types

a. Numeric Types

i. Integer

For example, Java includes four signed integer sizes: byte , short , int , and long .

Some languages, for example, C++ and C#, include unsigned integer types, which are simply types for integer values without signs.

A signed integer value is represented in a computer by a string of bits, with one of the bits (typically the leftmost) representing the sign.

Most computers now use a notation called twos complement to store negative integers.

In twos-complement notation, the representation of

a negative integer is formed by taking the logical complement of the positive version of the number and adding one.

Ones-complement notation is still used

by some computers. In ones-complement notation, the negative of an integer is stored as the logical complement of its absolute value.

ii. Floating-Point

Floating-point data types model real numbers.

Most languages include two floating-point types, often called float and double.

The collection of values that can be represented by a floating-point type is defined in terms of precision and range.

Precision is the accuracy of the fractional part of a value, measured as the number of bits.

Range is a combination of the range of fractions and, more important, the range of exponents.

IEEE floating-point formats:

(a) single precision,

(b) double precision

iii. Complex

Some programming languages support a complex data type. For example, Fortran and Python.

In Python, the imaginary part of a complex literal is specified by following it with a j or J —for example,

(7 + 3j).

Languages that support a complex type include operations for arithmetic on complex values.

iv. Decimal

Most larger computers that are designed to support business systems applications have hardware support for decimal data types.

Decimal data types store a fixed number of decimal digits, with the decimal point at a fixed position in the value.

COBOL, C# and F# languages have decimal data types.

Decimal types are stored very much like character strings, using binary codes for the decimal digits. These representations are called binary coded decimal (BCD).

b. Boolean Types

Their range of values has only two elements: one for true and one for false.

They were introduced in ALGOL 60 and have been included in most general-purpose languages designed since 1960.

c. Character Types

Character data are stored in computers as numeric codings. Traditionally, the most commonly used coding was the 8-bit code ASCII (American Standard Code for Information Interchange), which uses the values 0 to 127 to code 128 different characters.

Because of the globalization of business and the need for computers to communicate with other computers around the world, the ASCII character set became inadequate. In response, in 1991, the Unicode Consortium published the UCS-2 standard, a 16-bit character set. This character code is often called Unicode.

Unicode includes the characters from most of the world’s natural languages.

For example, Unicode includes the Cyrillic alphabet, as used in Serbia, and the Thai digits.

After 1991, the Unicode Consortium, in cooperation with the International Standards Organization (ISO), developed a 4-byte character code named UCS-4, or UTF-32, which is described in the ISO/IEC 10646 Standard, published in 2000.

The first 128 characters of Unicode are identical to those of ASCII.

Java was the first widely used language to use the Unicode character set. Since then, it has found its way into JavaScript, Python, Perl, C#, and F#.

Watch following video: