Summary: while (1000000000 <= 0) #1 billion
is being tested.
Is this too high of a value for an integer to be tested in Python or is my code(below) not executing the while loop for some other reasons?
I am trying to determine how long it would take to spend a billion dollars by spending $100/second while the money is also earning 1% interest per year:
currentAmount = 1000000000 # 1 billion
MONEY_SPENT_PER_SECOND = 100
days = 1 #up to 365
INTEREST_RATE_PER_DAY = .01 / 365
SECONDS_IN_DAY = 86400
MONEY_SPENT_PER_DAY = SECONDS_IN_DAY * 100 # $8,640,000
interestEarnedToday = 0
while(currentAmount <= 0):
print("In loop") #test to see if code is in loop, but this does not get printed
interestEarnedToday = INTEREST_RATE_PER_DAY * currentAmount
currentAmount = currentAmount + interestEarnedToday
currentAmount = currentAmount - MONEY_SPENT_PER_DAY
days = days + 1
But the while loop is never entered and I am not sure why? As print(currentAmount)
outputs 1000000000
so I feel like this indicates that python can handle integers this large. Thanks for any help.