You could with perhaps 20 times more programming, teach the program how to multiply, divide, add, and
subtract out to a large number of decimal places stored in an array. I might try that some day...
Or ...
... you might like to improve *this* !
]]>float sine(float x)
{
while ( x >= 360)
{
x = (x - 360);
}
/* insert formula for sine here*/
}
since adding 360 degree's to an angle has no effect on its sine, cosine or tangent, the value returned will be correct, and more accurate.
]]>'Note: dangle is angle in degrees and rangle is angle in radians
for dangle = 0 to 90 step 5
pi = 3.141592653589793238462643383279502884197169399375105820974944
rangle=(pi*dangle)/180
'Note: cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + ...
rangleSqrd=rangle * rangle
diver = 0
nextTerm = 1
cosineNow = 1
for iter=1 to 10
for d1 = 1 to 2
diver = diver + 1
nextTerm = nextTerm / diver
next d1
nextTerm = 0 - nextTerm
nextTerm = nextTerm * rangleSqrd
cosineNow = cosineNow + nextTerm
next iter
print "Cosine( ";dangle;" ) = ";cosineNow
next dangle
If it doesn't, I'll have a go at translating it for you.
Of course, if your program is such that you know the lengths of at least two of the sides of your triangle, you can compute the trig functions using SOH CAH TOA.
]]>Basicly I wan't to define the following functions: float sin( float x); float cos(float x); float tan(float x);
So I can just call sin(x) cos (x) or tan(x) anytime I need them.
]]>