Hi All,
I need to use ln function to read NTC sensor readings. if i use log(number , 2.71828182846) which yields to ln(number). but log function giving wrong value. Could you please tell how to log function in this controller.
Hi,
The CodeWarriror IDE help says:
#include <math.h>
double log (double x);
float logf(float x);
Description
log() computes the natural logarithm of x.
Return
ln(x), if x is greater than zero. If x is smaller then zero, NAN is returned; if it is equal to zero, log() returns negative infinity. In both cases, errno is set to EDOM.
So you should be sure:
#include <hidef.h>
#include "derivative.h"
#include <math.h>
int a;
volatile float y;
void main(void)
{
for(;;)
{
for ( a=100; a<10000; a+=100)
{
y = logf( a );
asm nop;
}
}
}
A full example project is attached.
Best regards,
Ladislav