The Spice of Life

The Spice of Life

16M Downloads

java.lang.ArithmeticException: Division undefined

Syndaryl opened this issue ยท 2 comments

commented

https://1drv.ms/t/s!AqTWbM9NKFyOqDjQHfFgCPUd9rs3

Crash occurs when interacting with cookie. My food history is, I think, empty due to recent death but I am in the diminishing returns phase.

S:food.modifier.formula=IF(count=0,1,((0.5+((((0.5+MAX(1-(count/cur_history_length),0.1)/2))*(((distinct_food_groups_eaten/(total_food_groups-1))+2)/3))/2))+(food_group_count/(total_food_groups-3)))/2.2)

commented

"An ArithmeticException is only thrown with the message "Division undefined" when you attempt to divide zero by zero."

You have to make sure to protect against things like this is in your formula. Likely due to this part, assuming count is 0 and cur_history_length is 0:

count/cur_history_length

commented

Aha, I was catching for the numerator being zero, but not the denominator.