Modular Division For Splitting Integers BUG?

Helloo everyone,
sorry to trouble you people, am sure this must be a simple problem but i can’t detect it, so could you help me out please?

here’s what i wanna do:
input from analog pin, parse data to a function to split it and store units in an array ( 1023 to become {1,0,2,3} )

i’ve figured out a piece of code partially working:
:cold_sweat: sorry dont know how to insert codes


int data[4];

void loop()
{
  delay(10);
  int sensor = analogRead(A0);
  moduloo(sensor);
}

void moduloo(int input)
{
  if (input > 0)
  {
    for( int i=0; i < 3; i++)
    {
      input = input / pow(10,i);
      data[i] = input % 10;
    }
  }
}

here’s the results i’ve got:
for 1023 : {0,1,2,3}
2345 : {0,2,4,5} ( tested this 1 ‘manually’ )

its appears to work fine for all units when i mess with the code for larger arrays except for the HUNDREDTH unit.
could you help this newbie out please.
thanks.

Use this:

void moduloo(int input)
{
  for( int i=3; i >= 0; i--)
  {
    data[i] = input % 10;
    input = input / 10;
  }
}

Note that there's no reason to exclude an input of zero.

Pete

Thanks Pete works like a charm.