why cant i turn a analog pin into a digital pin?

here is the code,

int pulses;
int deg = 0;
int encoderA = 15;//Yellow originals were 1
int encoderB = 16;//Blue originals were 2

int pulsesChanged = 0;

void setup(){
 Serial.begin(115200);
 Serial.println("k");
 pinMode(encoderA, INPUT);
 pinMode(encoderB, INPUT);  
 
 attachInterrupt(0, A_CHANGE, CHANGE);
 attachInterrupt(1, B_CHANGE, CHANGE);

}//setup

void loop(){
 if (pulsesChanged != 0) {
   pulsesChanged = 0;
   Serial.println(pulses);
 }
}

void A_CHANGE(){
 if( digitalRead(encoderB) == 0 ) {
   if ( digitalRead(encoderA) == 0 ) {
     // A fell, B is low
     pulses--; // moving reverse
   } else {
     // A rose, B is low
     pulses++; // moving forward
   }
} else {
   if ( digitalRead(encoderA) == 0 ) {
     // A fell, B is high
     pulses++; // moving forward
   } else {
     // A rose, B is high
     pulses--; // moving reverse
   }
 }
 // Make sure the pulses are between 0 and 359
 if (pulses > 359) {
   pulses = pulses - 360;
 } else if (pulses < 0) {
   pulses = pulses + 360;
 }

 // tell the loop that the pulses have changed
 pulsesChanged = 1;
}

void B_CHANGE(){
 if ( digitalRead(encoderA) == 0 ) {
   if ( digitalRead(encoderB) == 0 ) {
     // B fell, A is low
     pulses++; // moving forward
   } else {
     // B rose, A is low
     pulses--; // moving reverse
   }
} else {
   if ( digitalRead(encoderB) == 0 ) {
     // B fell, A is high
     pulses--; // moving reverse
   } else {
     // B rose, A is high
     pulses++; // moving forward
   }
 }
 // Make sure the pulses are between 0 and 359
 if (pulses > 359) {
   pulses = pulses - 360;
 } else if (pulses < 0) {
   pulses = pulses + 360;
 }

 // tell the loop that the pulses have changed
 pulsesChanged = 1;
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

That should work for the A1 and A2 pins of an Arduino UNO but won't work on a Leonardo because the analog pins start at 18, not at 14 like on the UNO.

What model Arduino and which pins?

You should use the names A1 and A2 if you mean those pins. That way it will use the right pins on Leonardo and Mega as well as UNO.

On boards that use the SMD version of the ATmega328P there are sometimes A6 and A7 pins. Those CAN'T be use for digitalRead() and digitalWrite().