How to check if a float value is a whole number

I am trying to find the largest cube root that is a whole number, that is less than 12,000.

processing = True
n = 12000
while processing:
    n -= 1
    if n ** (1/3) == #checks to see if this has decimals or not

I am not sure how to check if it is a whole number or not though! I could convert it to a string then use indexing to check the end values and see whether they are zero or not, that seems rather cumbersome though. Is there a simpler way?

14 Answers
14

Leave a Comment