I have three variables a, b and c. I want to make sure that after doing this:
c -= a*b
c is not negative.
I am doing this for now:
if a*b > c:
b = c // a
but for very large numbers, I still get negative value in c. what should I do?
To reproduce the error here are some sample numbers:
a = 5.195497498518083
b = 1.0813434626413702e+16
c = 5.614533816817397e+16
As stated in the comments, this might not be related to the how large the numbers are, but to the fact you are working with
float, and there are limitations. To illustrate the problem, check this in your REPL.But you could try and work with integers as suggested by @rioV8