I am trying to enter the decimal values using a keypad in ATMega8 Till now I have been able to enter only the integer values The code is given below
switch (
Its basic high school math, you need represent numbers in powers of 10.
Example -
138.25 = (1 * 10^2) + (3 * 10^1) + (8 * 10^0) + // integer part
(2 * 10^-1) + (5 * 10^-2) // Float part
I will not give you complete code, but you can use this idea
if (decimal)
{
a = a + b / (10 ^ pow);
}
else
{
a = a * 10 + b
}
pow
is the decimal digit - In above example (138.25) pow 2 is 1, and pow
for 5 is 2.
So you need to maintain counter for pow