Sorry guys, this morning I was extremely late, correct code was ret = sin(x).....
I followed code from DS50001456J just to test sin function.
Obviously included math.h and stdio.h (if not I had error due to undeclared sin):
#include <math.h> /* for sin */
#include <stdio.h> /* for printf, perror */
#include <errno.h> /* for errno */
double ret, x;
ret = sin(-1.0); // this gives me ret=-0.841, correct
x = -1.0;
ret = sin(x); // this gives me ret = -1.0, wrong: ret always the same of x
// missing perror check
Yesterday I spent one hour trying to understand what's wrong, I removed sprintf and increasing x to get code as simple as possible, I still got wrong value if sin argument not hardcoded.
I found issues about math functions but discussions were about 2003...
Today I reloaded code: I don't know if it was about compiler or Mplab, code is correctly working.
I apologize to waste your time.