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! :d


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

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support