I was translating some codes from C++ to vb6 and I notice the results output when using sine or cosine is different for instance, sin(0.224654) will yield a result of 0.222769 when it should be 0.0039209. Any idea why?
Thanks.
Printable View
I was translating some codes from C++ to vb6 and I notice the results output when using sine or cosine is different for instance, sin(0.224654) will yield a result of 0.222769 when it should be 0.0039209. Any idea why?
Thanks.
But Sine of 0.224654 is 0.222769070022729 :confused:
it does not quite match the value using excel worksheet functionsCode:?sin(.224654 *3.14159265/180)
3.92094192660541E-03
?cdec(sin(.224654 *3.14159265/180))
0.00392094192660541
Sin(0.224654) in vb6 and sin(0.224654) in Excel both give me 0.222769070022729
Yes that's because what you pass to sin is very imp.
Sin returns the sine of the given angle(Radians). if 0.224654 is an angle(Radians) then 0.222769070022729 is correct but if 0.224654 is degrees then you need to change it to angle(Radians) and then 0.0039209 is correct...
1 radian = 57.2957795 degrees
So
Code:Format(Sin(0.224654 / 57.2957795), "0.0000000") will give you 0.0039209
Kool. If your query is solved then do remember to mark the thread resolved :) Check my signature on how to mark a thread resolved ;)
the return from sin is a doubleQuote:
Sorry I am a little confused here, so which is which?
first example
by type casting to decimal you get the returned value as a decimal value
both are equal
sid converted the return to a formatted string, but i prefered to keep as a value