Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sin v/s sinf function in C

I am trying to use the sinf function in my C Program but it gives me an undefined reference error under MSVC 6.0, however sin works fine.

This make me curious to find the difference between sin and sinf.

What is the logical difference between sin and sinf ?

How can I implement my own sinf functionality?

like image 638
Viks Avatar asked May 15 '10 20:05

Viks


1 Answers

sin takes a double and returns a double - sinf takes a float and returns a float.

In other words sin is double precision and sinf is single precision.

If you're using an old compiler that doesn't have sinf you can implement it as:

#define sinf(x) (float)sin((double)(x))

like image 115
Paul R Avatar answered Sep 21 '22 12:09

Paul R