1. Precision Issues:
x = 1.0
y = 1e-16
result = x + y
print(result)
#clcoding.com
1.0
2. Comparing Floating-Point Numbers:
a = 0.1 + 0.2
b = 0.3
print(a == b)
#clcoding.com
False
3. NaN (Not a Number) and Inf (Infinity):
result = float('inf') / float('inf')
print(result)
#clcoding.com
nan
4. Large Integers:
result = 2 ** 1000
print(result)
#clcoding.com
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
5. Round-off Errors:
result = 0.1 + 0.2 - 0.3
print(result)
#clcoding.com
5.551115123125783e-17
0 Comments:
Post a Comment