Here is my test code that shows in the serial monitor what am talking about, displays a int value that has 32bits and an unsigned int that has 16bits.
byte temp;
unsigned int result = 7000;
unsigned int Display_RPM_A;
int Display_RPM_B;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
temp = result/1000;
Display_RPM_A = ~((1 << (16 - temp))-1) | ((1 << temp)-1);
temp = result/1000;
Display_RPM_B = ~((1 << (16 - temp))-1) | ((1 << temp)-1);
Serial.println("unsigned int value");
Serial.println(Display_RPM_A, BIN);
Serial.println("int value");
Serial.println(Display_RPM_B, BIN);
}
void loop() {
// put your main code here, to run repeatedly:
}
(Changed code above because the wrong lable was being printed).