I have small problem with a calculation, if i hard code the formula in the program then it works but i need that i work with variables
my formula is
x = 4899e-2;
result x = 48.99
but i won't to have the main value in a variable and also the exponent like this.
int exp;
long val;
x = val e-exp;
is't probably a stupid question but im stuck in it
Don't have my arduino etc set up here at the moment, but the function you want to check out is pow().
Demo C program:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char *argv[])
{
int number = 4855;
int exponent = 2;
float result;
result = number * pow(10, -exponent);
printf("Result: %f\n", result);
return EXIT_SUCCESS;
}
I have assumed from your comment you want to change the sign on the exponent, hence the unary "-" in front of the exponent. Beware rounding errors - on my PC this converted 4855 to 48.54999.