Help with modulo. 25%10 always rounds off to 6.
void processnumber(int number)
{
int x;
unsigned int ones;
int tens;
ones=(number)%10;
x=(number)-ones;
tens=x/10;
updatedisplay(ones,tens);
}
here sample code tries display on 2 digit 7 segment timer.
every time number has value of 5 @ end. example 25 rounds off 26
any suggestion amazing people?
thanks in advance!
{
int x;
unsigned int ones;
int tens;
ones=(number)%10;
x=(number)-ones;
tens=x/10;
updatedisplay(ones,tens);
}
here sample code tries display on 2 digit 7 segment timer.
every time number has value of 5 @ end. example 25 rounds off 26
any suggestion amazing people?
thanks in advance!
how use forum - please read.
quote
7. if posting code or error messages, use "code" tags
quote
11. tips getting out of post
post complete sketch (program code)! if don't waste time while people ask that. however, coding problems, if possible post "minimal" sketch demonstrates problem - not hundreds of lines of code. if problem goes away in minimal sketch, wasn't thought was.
Arduino Forum > Using Arduino > Programming Questions > Help with modulo. 25%10 always rounds off to 6.
arduino
Comments
Post a Comment