The math.h header in the PrizmSDK has a "sin" function in it, but it does not compile. It complains about an undefined reference to "_sin" in a different file. Does that mean that I have to implement sine myself? Or did I just do something wrong?
Somebody else recently encountered the same thing and reported it on github. libfxcg doesn't implement math functions like sin so if you want one you need to provide the implementation yourself.

The unimplemented functions should be removed, but nobody's done that yet:
we probably shouldn't provide prototypes for functions that we don't provide implementations for: these prototypes should be deleted.

It's a little annoying because compilers recognize these functions and can in some situations evaluate them at compile-time, but in that case a program using them would depend on compile-time evaluation and may as well hard-code the values it wants.
In case you do need to implement it, I have this algorithm for single-precision:


;a1=2^-3 * 11184804/2^23
;a2=2^-7 * 8946604/2^23
;a3=2^-13 * 13408017/2^23

Those constants can be exactly represented in single precision. The algorithm assumes you applied range reduction to get the input on [-π/4,π/4], so you'll need cosine as well:



(I'm not sure why I changed the format in my comments)
Again, range reduction to [-π/4,π/4].

These examples are in Z80 assembly and have the range reduction steps as well:
Note: I'm linking these because they have comments with pseudocode that might be useful; you don't need to understand the Z80 assembly Smile

Good luck Razz

Edit: Words, added note
Didn't PrizmSDK ship a compiled version of libm.a at some point?

On SuperH I have made this port of OpenLibm, which should work fine for the PrizmSDK provided you adjust the toolchain name (and install path if you don't want to use the compiler's internal lib folder).
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum