Hi ladies and gents,

I'm trying the next exercise:

Write a function value, wich adds the decimal numbers of 'n' together and return the result of this into main? For example:

0.1234 = 10

0.01234 = 10

0.3286 = 19

What Ive got so far is this:

```
short amount (float n)
{
short a = 0, i, totvalue = 0;
for (i = 0; i < sizeof (n); i++)
{
a = n = (n * 10);
n -= a;
totvalue += a;
}
return totvalue;
}
int main()
{
double a = 0.1234;
cout<<"Value = " << amount(a) <<endl;
return 0;
}
```

Problem is, when I run threw the loop in the function and arrive at the fourth digit '4', the compiler changes the number into '39997' and I get a wrong result :o

Also, is it possible to change the working of the loop using binary operators?

Thanks for the help :!: