These are two types of numeric constants:-
(a) Integer Constant
(b) Real/ Floating Point Constant
Integer constant -
These are the group of digits and a optional size at least one digit is required. There are three types of integer constant-
(i) Decimal Number System (0 to 9) base (10)
Example:
-12 16.700
+12 16.700
0 $16,700
1425 16 000
(Valid) (invalid)
(ii) Octal Number System (0 to 7) base (8)
Examples: -- octal number always starts with 0
056 24
0456 0386
0 05.36
067 (invalid)
(valid)
(iii) Hexadecimal Number System (0 to 9 & A to F) base (16)
Examples: --- Hexadecimal number starts with ox
oxaf 0345
oxabc ox4SH2
ox Hex 4567
(valid) (invalid)
Important points about Integers Constants
(a) An integer constant must have at least one digit.
(b) It must not have a decimal point
(c) It could either positive or negative.
(d) If no sign precedes an integer constant it assumed to be positive.
(e) No commas or blanks are allowed within an integer constant.
Real constant/Floating point constant
We cannot represent qualities that vary continuously such distance, temperature, price and so on. These qualities are represented by numbers containing fractional part like 9.456 such numbers are called real (or floating point) constant.
Examples:
1.0 890
-0.5678 -1/2
46000000.90 8.
-0.00005674 .8
(valid) (invalid)
Important points about Real/Constant or Floating Point Constant
(a) A real number must have at least one digit
(b) It must have a decimal point.
(c) It could be either positive or negative.
(d) Default sign is positive.
(e) No commas and blanks are allowed in real.
(f) A real number may also be expressed in exponential (or scientific notation).
(g) Embedded white space is not allowed.
Mantissa e exponent
Exponential notation is very useful for representing numbers that are either very large or very small in magnitude.
For example: 76 00000000 7.5EI0
-0.000000368 -3.68E-7
Mantissa: Is an either real number expressed in decimal notation or an integer.
Exponent: Is an integer number with an optional plus or minus sign. The exponent can be written in either lower case or upper case.
Important Points about Mantissa and Exponents
(a) The Mantissa part and the Exponent part should be separated by a letter 'e' or 'E'.
(b) The Mantissa part may have a positive or negative sign
(c) Default sign of Mantissa part is positive.
(d) The Exponent must have at least one digit which must be positive or negative integer.