[go: up one dir, main page]

0% found this document useful (0 votes)
47 views4 pages

PPL

PPL sppu unit 2

Uploaded by

inventor 110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
47 views4 pages

PPL

PPL sppu unit 2

Uploaded by

inventor 110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
Principles of ‘Structuring the Data, Computations and Program Elementary Data Types a Primitive Data Types © The primitive data types are elementary data types which are not built from some other types. * The values of primitive data types are atomic and cannot be decomposed into simpler constituents. ‘* Many times the built in data types can be interchangeably used with built in data type but there are exceptions. For example - enum in C is a primitive data type which is used to define new constants. ‘* Any programming language has a predefined set of built in data types. This built in data type reflects the behavior of underlying hardware. * Due to built in data type, the values are interpreted differently using hardware instructions. * Following are the types of built in types of programming languages. Numeric types | Boolean type Character type] [= Integer |» Floating- point [= Complex L» Decimal Fig. 2.1.1 Data types 4) Numeric Types : © Integer: © This is the most commonly used data type. © The integer data types can be signed or unsigned data types. o In Java there are singed integer data types such as byte, short, int and long. o In C+ unsigned integer data types are simply the integer values without signs. ‘The unsigned integer data types are typically used for binary data. TECHNICAL PUBLICATIONS® - An up thrust for knowledge Principles of Programming Languages 2-3 Structuring the Data, Computations and Program + Floating Point: © The floating point data type is used for representing the real numbers. ‘© On most of the computers the floating point numbers are stored in binary number format. © Floating point values are represented as fractions and exponents. © In most of the languages, there are two types of floating point values - float and double. * Complex: © Complex values are represented as pair of real and imaginary part. © The imaginary part of complex number is represented as literal such as i or. © For example 5 + 7i is a complex number. © Python is a programming language that supports the complex data type. * Decimal © The decimal data type is used to support business systems applications. © This is a type of data type that store fixed number of decimal digits with decimal point at a fixed position in the value. © The languages like COBOL and C# makes use of decimal data type. ‘© The decimal data type values can be stored using a special representation called Binary Coded Decimal(BCD) 2) Boolean Types : * This data type define only two values TRUE and FALSE. * In Boolean algebra the Boolean data type is used. ‘© The basic operations performed are and, not , or. 3) Character Type : © The single character value is represented using char data type. * InC the character type variable is. char choice; ‘Type Structure of C++ ‘The type structure of C++ is divided into two main categories - Fundamental types and derived types. * The fundamental type is - integer and float. The integer data type is classified into int, char, short, long. The float data type is classified into float and double. TECHNICAL PUBLICATIONS® - An up thrust for knowledge Principles of Programming Languages 2-5 _ Structuring the Data, Computations and Program Byie Char Shot Int Long Float Double Fig. 2.1.3 Types structure of Java The built in data types : Various data types used in Java are byte, short, int, long, char, float, double and boolean. byte This is in fact smallest integer type of data type. Its width is of 8-bits with the range -128 to 127. The variable can be declared as byte type as byte ij short This data type is also used for defining the signed numerical variables with a width of 16 - bits and having a range from ~32,768 to 32,767. The variable can be declared as short as short a,b; int This is the most commonly used data type for defining the numerical data. The width of this data type is 32-bit having a range 2,147,483,648 to 2,147,483,647. The declaration can be int pas long Sometimes when int is not sufficient for declaring some data then long is used. The range of long is really very long and it is -9,223,372,036854,775,808 to 9,223,372,036,854,775,807. The declaration can be long xy; Principles of Programming Languages 2-6 Structuring the Data, Computations and Program float To represent the real number(i.e. number that may have decimal point) float data type can be used. The width is 32-bit and range of this data type is 3.40282347 x 10%, 1,40239846 x 10°*, double To represent the real numbers of large range the double data type is used. Its width is 64-bit having the range 1.8 x 10°, 4.9 x 10°™* char This data type is used to represent the character type of data. The width of this data type is 16-bit and its range is 0 to 65,536. boolean Boolean is a simple data type which denotes a value to be either true or false. Character String Types A character string type is one in which values are sequences of characters. EXER design issues ‘The two most important design issues for character string types are - 1) Is it a primitive type or just a special kind of character array ? © Cand C++ use char arrays to store char strings. These char strings are terminated by a special character null. * In Java strings are supported by String class whose value are constant string, and the String Buffer class whose value are changeable and are more like arrays of single characters. © C#and Ruby include string classes that are similar to those of Java. «Python strings are immutable, similar to the String class objects of Java. 2) Is the length of objects static or dynamic ? ‘The length can be static and set when the string is created. For example - in C, C++, Java we can have static length string. © When the string length is dynamic then it has no maximum limit. For example - Perl and JavaScript provide this kind of facility.

You might also like