turw
October 9, 2013, 1:41pm
1
Hello,
how it's possible to use log10(x) to arduino code ?
i want to use the log10(x) where x is a float in arduino code.
my code is :
#include <math.h>
float tab [ ] = {2,3; 5,9; 0,96};
float log_tab [3]={0; 0; 0};
for (int i=0, i<3, i++)
{
log_tab [i] = log10(tab[i]);
}
Thanks
guix
October 9, 2013, 1:50pm
2
Here is how to write a float:
2.3
And how to put elements in an array:
{ a, b, c }
Edit: in theory a float should be written 2.3f to differenciate it from a double, but doubles and floats are the same thing for Arduino (except the Due maybe?)
MarkT
October 9, 2013, 1:55pm
3
#include <math.h>
float tab [] = {2.3, 5.9, 0.96}; // correct syntax for floats and array initializers
float log_tab [3] ; // how to declare an uninitialised array
for (int i=0, i<3, i++)
{
log_tab [i] = log10 (tab[i]);
}
turw
October 9, 2013, 8:42pm
4
Thanks a lot MarkT and guix for reply.