is this rotary encoder functioning correctly? (rotary encoder inconsistent )

Hello I had problems using a rotary encoder as an input device.
after a while I decided to test it (on analog pins) to find out where the error was.
this is the code i used:

  int INclk;
  int INdt;
  int INclkOLd;
  int INdtOLd;
  int counter = 0;  
  int dt = A0;
  int clk = A2;

void setup() {
  Serial.begin (9600);
  pinMode(clk, INPUT);
  pinMode(dt, INPUT);
  INclkOLd = analogRead(clk);
  INdtOLd = analogRead(dt);
}

void loop() {
  INclk = analogRead(clk);
  INdt = analogRead(dt);
if (INclk ==! INclkOLd || INdt ==! INdtOLd){
    Serial.print(INclk);
    Serial.print("____");
    Serial.println(INdt);
    
    }
    INclkOLd = analogRead(clk);
    INdtOLd = analogRead(dt);
}

So if something changes in the CLK or DT values, the following is printed out in the serial monitor:

“CLK” ____ ”DT”

that is an example, what is written in the serial monitor when I turn it 10 clicks clockwise:
1023____0
0____0
0____1023
1023____0
1023____0
1023____0
1023____0
1023____0
0____0
0____0
0____0
1021____0
0____0
1023____0
1023____0
0____0
1023____0
1023____0
0____0

and when I turn it 10 clicks counterclockwise:

0____0
0____1023
0____1023
0____0
0____0
1023____0
0____0
0____1023
0____0

do you know what is going on there?

try this concept out:

  int dt = A0;
  int clk = A2;
  int counter;

void setup() {
  Serial.begin (9600);
  pinMode(clk, INPUT);
  pinMode(dt, INPUT);
}


void loop() {
  static int LastState;
  int Clock;
  if(LastState == (Clock = digitalRead(clk))) return; // No Change
  LastState = Clock;
  if(Clock == 0) return; // Clock Went Low
  //Clock went High
  (digitalRead(dt))? counter++: counter--;
  Serial.println(counter);
}

Z