Question about adjusting motor speed

Hi, I am using rotary encoder and Brushless DC motor, but when I change motorspeed to 1, the encoder cannot keepup with number of the pulse and the readout value stays constant and motor roates nonstop. However when I change to 0.9 and below, they are rotate at same speed (but still significanlty slower than value of 1) regardless of input value however encoder is able to keepup with pulse. I want the encoder to keepup the pulse readout at the maximum speed. Or should I go about adjusting input speed value from 1~0.9? Any suggestions please?

#define DIR_PIN 8
#define STEP_PIN 9
#define motorenable 10

int encoder0PinA = 2;
int encoder0PinB = 3;

volatile long encoder0Pos = 0;
volatile int encoder0PinALast = LOW;
volatile int n = LOW;
volatile int m = LOW;
int valNew = 0;
int valOld = 0;

long temp;

void setup()
{  
  pinMode(DIR_PIN, OUTPUT);
  pinMode(STEP_PIN, OUTPUT);
  pinMode(motorenable, OUTPUT);
  
  pinMode (encoder0PinA,INPUT);
  pinMode (encoder0PinB,INPUT);  
  Serial.begin (115200);  
  attachInterrupt(1, CountA, CHANGE);  
  attachInterrupt(0, StateB, FALLING);
}

void loop()
{  
  long pulse = 42000;
  int motor_speed = 0.1;
  int dir = (pulse < 0)? HIGH:LOW;
  digitalWrite(motorenable, HIGH);
  digitalWrite(DIR_PIN,dir); 
  digitalWrite(STEP_PIN, motor_speed);
  
  if(temp >= pulse)
  {
    digitalWrite(motorenable, LOW);
    delay(100000);

  }
  Serial.print("Position: ");
  Serial.println(temp);   
}

void CountA()
{  
  n = digitalRead(encoder0PinA);   
  if ((encoder0PinALast == LOW) && (n == HIGH)) 
  {     
    if (m == LOW) 
    {       
       temp = encoder0Pos--;   
    }     
    else 
    {       
       temp = encoder0Pos++;   
    }   
  }
}
void StateB()
{  
  m = digitalRead(encoder0PinB);
}

int motor_speed = 0.1; is just the same as int motor_speed = 0.9; is the same as int motor_speed = 0;
Fractions assigned to integers are truncated.

'temp' is modified in an ISR and is not declared volatile.