Search code examples
vb.nettranslationqbasic

ATN from QBasic to VB.Net


I am currently translating a program from QBasic to VB.Net and I have this line of code :

RSA = 270 + 180 / PI * (ATN(ABS(X(Z, 2) / X(Z, 1))))

I translated it as

RSA = 270 + 180 / PI * (Math.Atan(Math.Abs(arrayX(z - 1, 2 - 1) / arrayX(z - 1, 1 - 1))))

for VB.Net but the results are different. Here are some informations :

PI = 3.141592654

And for my test
I used "6.8929106501697825" for my X(Z, 2) value
I used "-5.08864764726704" for my X(Z, 1) value

The result for QBasic is : 323.9964
The result for VB.Net is : 323.5636369944437

Did I do something wrong?

Thanks


Solution

  • I just leanrned that there is no problem in my calculation. The reason why the result is different is just because Visual Basic is more precise so my calculation is just more accurate.

    Thanks a lot for answers!