I am trying to separate a decimal number by digits.
from the number 12.34 to get the first digit we can multiply (12.34100)/1000.
But Arduino is not letting me do ((12.34100)/1000)%1000
How to do this on a float data type to get the 3rd digit and the decimal digits..?
Sorry.. I didn't get you..
Decide how many digits right of the decimal point you want. Multiply by a multiple of 10 to move that number of digits left of the decimal point. Cast the result to int, and use % to extract the individual digits.
So, if you want 3 digits after the decimal point, multiply by 1000.0 before casting the result to int. 1.234 then becomes 1234.
My mistake was.. I should have done ((12.34*100)/100)%10
My mistake was… I should have done ((12.34*100)/100)%10
You’ll still have the same problem unless you explicitly force a conversion of the intermediate result to an integer data type (as already suggested).
Multiplying a float by 100 and dividing the result by 100 will not achieve much.
I would convert it to string and read the digits as chars