0

This..

awk 'BEGIN{print sin(2.6261)}'

should (and normally does) yield 0.492964 but it yields 0.909297 on my embedded motherboard running BusyBox linux. The board I have is a DMP Vortex 86SX. I dont think it has a maths co-processor. The spec of the board is here...

http://www.dmp.com.tw/tech/vortex86sx/

I need some way to do a sin from within my app written in C and built with Kdevelop - without it I'm really stuck - Any help much appreciated - thank you - rich

Sanoob
  • 2,466
  • 4
  • 30
  • 38
RichEarle
  • 21
  • 3
  • Have you tried asking for sin (0.5155) instead? it's possible that trig functions will only work in a certain domain. (0.5155 = pi - 2.6261, and should yield the result of your original value). – James Snook Mar 28 '14 at 16:14
  • Thank you James, you're correct. pi-x does yield the correct result so I have tested the value I want the sin of.. if it's greater than pi/2 I take the sin of pi-x instead. That get's me going. Thanks again. – RichEarle Mar 31 '14 at 09:22
  • I've added this as a proper answer as it seems to be correct. – James Snook Mar 31 '14 at 13:57

1 Answers1

0

Have you tried asking for sin (0.5155) instead? it's possible that trig functions will only work in a certain domain. (0.5155 = pi - 2.6261, and should yield the result of your original value).

Trig functions normally reduce the domain for you and then calculate the result. However doing the reduction may be expensive for an embedded system (and can often be done more efficiently yourself if you know the range the value will be in).

James Snook
  • 4,063
  • 2
  • 18
  • 30