Answer the question
In order to leave comments, you need to log in
How to fix function argument type mismatch error?
There is a code
Function f(x As Single) As Single
f = (100 - x) * (75 - x) * x
End Function
Sub program()
eps = 0.00001
l = 0 / 2
r = 75 / 2
Do While r - l > eps
m = (r + l) / 2
If (f(l) - f(l + eps)) * (f(m) - f(m + eps)) > 0 Then
l = m
Else
r = m
Loop
Cells(1, 1).Value = (r + l) / 2
End Sub
f(l)
doesn't match the expected type. Answer the question
In order to leave comments, you need to log in
Check what the formula in function f returns and see if it matches the Single definition:
The Single value type is a 32-bit single-precision number with values from negative 3.402823E38 to positive 3.402823E38, or positive or negative zero
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question