True of False
Why is this False: a = 3**45 == int(float(3**45)) print(a) When this is True: a = 3**3 == int(float(3**3)) print(a) I don't understand this logic.
It is linked to something called limited floating point accuracy or precision: https://en.m.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems Basically, floats in their decimal state have to be represented by binary system (deep, deep down in the "computer core" :) This causes problems for all numbers which cannot be precisely represented using powers of 2 - so basically most real numbers. float(3) is represented by a number closest to its representation (it might be something like 3.000000000000000004) which for "small" computations makes no difference, but for large operations likes exponentiation, the inaccuracy might result in a bit different, unexpectedly different, number. Please note that for numbers which are exactly the power of 2, this does not happen. 4.0**100 == 4**100
Try printing this print(int(float(3**34))) print(3**34)
It only started changing at 3**34. Higher level (or lower level) SoloLearners who always gets this question right in the challenge section, come and explain it o!!!
Abhay I still do not understand. Have you tried this: print(int(float(3**33))) print(3**33) Does it mean for larger exponentials, it changes or something?
How do I generate a list with <N> unique elements randomly selected from another (already existing) list?
Given three integer matrices A(m*n),B(m*n) and C(m*n) . Print the one with more zero elements. beside code
I'm coding this for hours & can't make the value of the 5 random numbers round off to 2 decimal places like in the examples
Overloading + operator