Numeric Literals in Python
Numeric Literals in Python
* A numeric literal is a literal containing only the digits 0-9 , an optional sign character (+ or - ) , and a possible decimal point. Commas are never used in numeric literals.
* If a numeric literal does not contain a decimal point, then it denotes an integer (int) value.
* If a numeric literal contains a decimal point, then it denotes a floating-point (float) value.
Limits of Range in Floating-Point Representation
* There is no limit to the size of an integer that can be represented in Python. But floating-point values have both a limited range and a limited precision.
* Python uses a double-precision standard format (IEEE 754) providing a range of 10 -308 to 10+ 308 with 16 to 17 digits of precision.
Arithmetic overflow:
Arithmetic overflow occurs when a calculated result is too large in magnitude to be represented .
Example :
>>>1.5e200 * 2.0e210
inf
This result in the special value inf ("infinity") rather than the arithmetically correct result 3.0e410, indicating that arithmetic overflow has occurred.
Arithmetic underflow:
Arithmetic underflow occurs when a calculated result is too small ion magnitude to be represented.
Example:
>>>1.0e2300/1.0e100
0.0
This results in 0.0 rather than the arithmetically correct result 1.0e2400, indicating that arithmetic underflow has occurred.
Comments
Post a Comment