+ 2
I wrote print ( 3.14 + 1 )and it gave me output 4.140000000000001
4 Respostas
+ 5
for storing decimal numbers most programming languages use floating point specification to store them in 32b or 64b locations. lets say that python uses 64b (not realy sure if this is true, but it does not matter for the sake of explanation). that means that any decimal number must be represented with 64 values where each must be 1 or 0. this gives a finite amount of combinations ( very big finite, but still finite), so we come to the problem of representing some numbers, which gives some value error for them. if you execute
print(0.2+0.1)
you will get 0.30000000000000004 when you expect 0.3 . now this may seem like a terrible thing, since your program is not giving you correct answers, but note that the error is on the 17th digit, which means the error is very terribly small. so basically, while 4.14 cannot be accurately represented , it can be represented acurately enough for most purposes. note that python may make some optimizations to get more accurate values in some situations which i am not aware of, but this is the basic idea.
0
basically the python auto derive the value
for numerical it often awake as float data type
and ur operation also float
0
it add some amt of garbage value I think so
- 1
Dont know