I am writing functions with the following equation:
P = 10 ^ (A - B9 / ( T C ))
Z = C * Exp ( -k * t)
I am using the following syntax:
Answer 1:
Function P(a As Integer, b As Integer, c As Integer, t As Integer) As Integer
P = (10 ^ a) / 10 ^ (b / (t c))
End Function
Answer 2:
Function Z(c As Integer, k As Integer, t As Integer) As Integer
Z = c / Exp(-k * t)
End Function
The answers are not coming out as accurate.
Please let me know where I am lacking.
CodePudding user response:
The equations are different from the original, you should also post the expected result from certain numbers, try this:
Function P(a As Integer, b As Integer, c As Integer, t As Integer) As Integer
P = 10 ^ (a - b / (t c))
End Function
Function Z(c As Integer, k As Integer, t As Integer) As Integer
Z = c * Exp(-k * t)
End Function
Also you must take into account the max value that holds the Integer
that is: 32767
so the program will overflow when that variable exceeds that value, you can read more about data limits here