Bug when printing number with trailing zeros

I'm writing an itoa function for my kernel, so there is no standard library available. This is what I got so far:

#include <string.h>

void itoa(int number, char* str) {
  int i = 0;
  while(number != 0) {
    str[i] = number%10+'0';
    number = number / 10;
    i++;
  }
  str[i] = '\0';
  reverse(str);
}

However, when I use the number 022 and print it, it shows 18. If I remove the trailing zero everything works fine again. How does this come?