how to solve this problem?
suppose
DOUBLE number = 23.4;
int digit1 = int(t) / 10; // takes the value 2 (it is OK)
int digit2 = int(t) % 10; // assumes value 3 (it is OK)
double temp = int(number) - number; // temp takes the value -0.4 (it is OK)
temp = abs(temp); // temp takes the value 0.4 (it is OK)
int W = temp * 10; // 0.4 * 10
Serial.println(W); is 5 !!! (why is it always 1 more) ????
How to get around this, in total it needs to write the first number after the decimal point to the INT variable. Any other solution ?
suppose
DOUBLE number = 23.4;
int digit1 = int(t) / 10; // takes the value 2 (it is OK)
int digit2 = int(t) % 10; // assumes value 3 (it is OK)
double temp = int(number) - number; // temp takes the value -0.4 (it is OK)
temp = abs(temp); // temp takes the value 0.4 (it is OK)
int W = temp * 10; // 0.4 * 10
Serial.println(W); is 5 !!! (why is it always 1 more) ????
How to get around this, in total it needs to write the first number after the decimal point to the INT variable. Any other solution ?