I am creating a problem which requires me to find the cube root of certain numbers, some of them have whole number roots, but a lot of them don\'t.
I have numbers li
It's more straightforward to avoid the problem! For example:
mx = 12000 # maximum for cubes
crmx = int(mx**(1/3)) + 1 # largest test integer
result = max([n for n in range(crmx) if n**3 < mx])
# result = 22
Floating point arithmetic is always approximate. For example:
.99999999999999999.is_integer() gives True
.9999999999999999.is_integer() gives False
(Your interpreter's mileage may differ.)