Page 146 - Computer science 868 Class 12
P. 146
• double: The double data type is a double-precision 64-bit IEEE 754* floating point or equivalent to 8 bytes. For
decimal values, this data type is generally the default choice. The double data type can store fractional numbers
from 1.7e-308 to 1.7e+308, i.e., values up to 16 decimal digits. Note that you should end the value with a “d”. The
default value is 0.0d.
For example: double a = 36.14264d, double b = 748.64789d
Let us summarise the above details in the table given below.
Type Size Default Range of values that Format
value can be stored
Float 4 bytes/32 bits 0.0f 3.4e-038 to 3.4e+038 float a=10.67f
double 8 bytes/64 bits 0.0 or 0.0d 1.7e-308 to 1.7e+308 double b=1234.87674
Note: The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point
arithmetic established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE).
Character Type
Character data type can hold character data. It is represented by char which is discussed below.
• char: The char data type stores the character constants in the memory. The char data type is a single 16-bit Unicode
character. It assumes a size of 2 bytes, but basically, it can hold only a single character because char stores Unicode
character sets. It has a minimum value of ‘\u0000’ (or 0) and a maximum value of ‘\uffff’ (65,535). The default value
is ‘\u0000’.
For example: char ch = ‘x’
The above description is tabulated below.
Type Size Default Range of values that Format
value can be stored
Char 2 bytes\16 bits \u0000 ‘\u0000’ (or 0) to char c = ‘a’
‘\uffff’ (or 65,535) char d= ‘\u0041’
Boolean Type
Boolean data type can take only two possible values. It is represented by a boolean which is discussed below.
• boolean: The Boolean data type is used to store only two possible values: true and false. This data type is used for
simple flags that track true/false conditions. The Boolean data type specifies one bit of information. The default
value is false.
For example: boolean a = false
The specifications of the boolean data type are illustrated below.
Type Size Default value Range of values that Format
can be stored
Boolean 1-bit False true Or false boolean a = true;
Note: 1. Integer and Float data types are numeric data types.
2. Character and Boolean data types are non-numeric data types.
5.1.3 Non-Primitive Data Types
Non-primitive data types are also called Reference Data Types or Composite Data types. They contain a memory
address of a variable or value because the reference types won’t store the value of the variable directly in memory.
144144 Touchpad Computer Science-XII

