 }
 
 void displayNumber() {
-  //turn on the LEDs accoring to the number from 0-9
-  int dispNum=num[refreshLoop];
-
-  if (dispNum == -1)
-    clearLEDs();
-  else
-    updateShiftRegister(numbers[dispNum]);
-}
-
-void splitNumber(int n) {
-  //takes the input n and puts into the array num, split in ones, tens, hundreds, and thousands place
-  
-  //clear previous values of the num array, -1 value allows checking to see if a new value has been placed
-  for (int i=1; i<4; i++)
-    num[i] = -1;
+  //turn on the LEDs accoring to the number stored in array num on the refresh cycle
+  updateShiftRegister(num[refreshLoop]);
+}
+
+void splitNumber(double n) {
+  //takes the input n and puts into the array num, split into 4 digits from lsb to msb
+  double decimalPart = 0.0;
+  int wholePart = 0;
+
+  //clear previous values of the num array
+  for (int i=0; i<4; i++)
+  {
+    num[i] = off;
+    negative = false;
+  }
+
+  if (n < 0) {
+    n = abs(n);
+    negative = true;
+  }
+
+  decimalPart = fmod(n,1.0);
+  wholePart = n - decimalPart;
+
+  int splitPosition = splitWhole(wholePart);
+
+  if(negative)
+    num[splitPosition] = minus;
+}
+
+int splitWhole(int n) {
+  //takes the input n and puts into the array num, and return the array position
+  int whole[] = {-1,-1,-1,-1, -1};
+  int wholePosition = 0;
+  int j=0;
+
+  if (negative){
+    if (n > 999) {
+      n = 0;
+      negative = false;
+    }
+    else
+      j = 1;
+  }
 
   //if n is 0-9
   if (n < 10) {
-    num[0] = n;
+    whole[0+j] = n;
   }
   //else if n is 10-99
   else if (n < 100) {
-    num[1] = n / 10;
-    num[0] = n % 10;
+    whole[1+j] = n / 10;
+    whole[0+j] = n % 10;
   }
   //else if n is 100-999
   else if (n < 1000) {
-    num[2] = n / 100;
+    whole[2+j] = n / 100;
     n = n % 100;
-    num[1] = n / 10;
-    num[0] = n % 10;
+    whole[1+j] = n / 10;
+    whole[0+j] = n % 10;
   }
   //else if n is 1000-9999
   else if (n < 10000) {
-    num[3] = n / 1000;
+    whole[3+j] = n / 1000;
     n = n % 1000;
-    num[2] = n / 100;
+    whole[2+j] = n / 100;
     n = n % 100;
-    num[1] = n / 10;
-    num[0] = n % 10;
+    whole[1+j] = n / 10;
+    whole[0+j] = n % 10;
   }
   //else n is bigger than the display, so display 0
   else
-    num[0] = 0;
+    whole[0] = 0;
+
+  for(int i=0; i<4; i++) {
+    if(whole[i]!=-1) {
+      num[wholePosition] = numbers[whole[i]];
+      wholePosition++;
+    }
+  }
+
+  return wholePosition;
 }
 
 void updateShiftRegister(byte leds) {

 |___| .
   D   Dp

    A   B   C   D   E   F   G   Dp  Hex    Dec
________________________________________________
0 | 1   1   1   1   1   1   0   0 | 0xfc | 252
1 | 1   1   0   0   0   0   0   0 | 0x60 | 96
2 | 1   1   0   1   1   0   1   0 | 0xda | 218
3 | 1   1   1   1   0   0   1   0 | 0xf2 | 242
4 | 0   1   1   0   0   1   1   0 | 0x66 | 102
5 | 1   0   1   1   0   1   1   0 | 0xb6 | 182
6 | 1   0   1   1   1   1   1   0 | 0xbe | 190
7 | 1   1   1   0   0   0   0   0 | 0xe0 | 224
8 | 1   1   1   1   1   1   1   0 | 0xfe | 254
9 | 1   1   1   0   0   1   1   0 | 0xe6 | 230
*/
byte numbers[] = {0xfc, 0x60, 0xda, 0xf2, 0x66, 0xb6, 0xbe, 0xe0, 0xfe, 0xe6};

//set cathode pins, controls which digit is displayed
const int digits[] = {4, 5, 6, 7};

//set pins for 74HC595 8-bit register to control anodes, controls which segments display
const int dataPin = 8;
const int latchPin = 9;
const int clockPin = 10;

const long refreshInterval = 10; //refresh delay in microseconds
long previousRefresh = 0; //previous refresh time
int refreshLoop = 0;  //counter for refreshing loop

int num[] = {0,-1,-1,-1};  //array for display numbers, {ones, tens, hundreds, thousands}

void setup() {
  //setup  pin modes to output

   digitalWrite(latchPin, HIGH);
}


//global variables for the test function
const long testInterval = 10; //counter delay in milliseconds
long previousTestTime = 0; //previous count time
int testLoop = -999; //counter for counting loop
int resetTestLoop = 10000;

void testCaseAllNum() {
  //test case, a loop timer that runs through each integer from 0 to 9999
