Theta = R / (Q * Q * Q)
If Abs(Theta) > 1 Then
If Theta > 0 Then Theta = 1
If Theta <= 0 Then Theta = -1
End If
Theta = Application.WorksheetFunction.Acos(Theta) / 3
I am wondering first of all, why there is a (double) definition in the C code since theta has been defined previously as double in that code. I am assuming secondly that the VBA Abs is the same as the C code fabs. Lastly, I'm wondering if there is any reason to believe that a calculation of Acos on a Sun machine would be any different from that calculated on a windows PC. I ask because the answers I'm getting from my code are significantly different from the original C code. The section of code here is the only part about which I have doubts.
Why is the redefinition of theta ("(double)") being used in the following line of code when theta has been defined as double earlier in the C program?:
If you call if(fabs(theta > 1.))[*], you would probably get a error about an ambiguous call to an overloaded function. casting the result of theta > 1. to double removes the ambiguity.
[*] Your missing a closing parenthesis in you post.
I assumed that the "(double)" was redundant and that my VBA code would therefore work:
If Abs(Theta) > 1 Then
If Theta > 0 Then Theta = 1
If Theta <= 0 Then Theta = -1
End If
As I say though, my results do not match with those coming from our Sun based software, if not because of these lines than because of some others. I may need to find a C expert to help with this - can anyone recommend someone in the Denver area? I'm only converting about 50 lines of C code.