Converting large numbers for digital display

I've been tackling a big first 'for fun' project but have run into some issues.
I've daisy chained together a total of 8 75HC595 shift registers. Each 8-bit shift register is dedicated to its own 7 segment display (so the last pin on each chip isn't hooked to anything). The main goal is to take a number that can range from 0 to 99,999,999 and display it as it's given value on the combined 8 displays. That number will be randomly generated in the code (and I've figured out that much with no problem). However, I'm clueless on how to develop and shift the sequence of bits that I need to display the created number on the display. Any help and examples would be greatly appreciated!

First step is to separate your number into digits. Think about how you might do this with division and the modulo operator to find the remainder.

Next, you can have an array of 10 bytes, one for each digit, that hold the bit patters you need to shift out. After that it is just a simple matter of picking the right bit pattern for each digit and shifting it out.

Here’s a look at some code to drive a single 7 seg from an Arduino. While this doesn’t involve any shift register, perhaps you can see what I mean with the array of bit patterns. Yours will be much simpler since you don’t need to deconstruct that byte into a bunch of digitalWrite statements, you can just shift the byte out as it is.

byte digits[] = {0b1111110 , 0b0110000, 0b1101101, 0b1111001, 0b0110011, 0b1011011, 0b1011111, 0b1110000, 0b1111111, 0b1111011};

// pins to segments g,f,e,d,c,b,a
byte pins[] = {3,4,5,6,7,8,9};

void displayNumber(int aNumber) {  
  for (int i = 0; i < 7; i++) {
    digitalWrite(pins[i], digits[aNumber] & (1 << i));

void setup(){
  for (int i = 0; i < 7; i++){
    pinMode(pins[i], OUTPUT);

void loop(){
  for (int i = 0; i < 10; i++) {

I was thinking of obtaining the digits with a bunch of 'if' expressions but knew there'd be a far more efficient way. I think experimenting around with the remainder is exactly what I'm looking for. I honestly don't know why I didn't think of doing that first. And maybe I'll give a stab at trying a 1byte pins, 2byte pins,.... -> 6byte pins. Not sure on how to explain my thought process since I haven't had any formal experience. But I think what you've shown me has my head in the right direction. Thanks!

Pay no attention to the pins array. Those were the pins on the Arduino that I had my 7 segment hooked to. You are using shift out and not all those digitalWrite lines in for loops. Your code will look COPMLETELY different from mine. I only gave that to you as an example of how to think about keeping your bit patterns in an array. Not as any example of how to actually accomplish what you want to do.

the digits array is the one I wanted you to look at. So your diplayDigit function might look like:

void displayDigit(int dig){
   shiftOut(aPin, anotherPin, theOrder, digits[dig]);

The point is that you have your bit patterns in an array and use the digit you want to display as an index to get the right bit pattern.