Serial.write() datatype issue in application @ xbee(API frame)

Project overview: (This is programming prob not a xbee prob), I have 5 int values which i want wirelessly send to another xbee. "My problem is how to give hexvalues(0x4E) in Serial.write() when i have an integers values(say current, voltage etc) ??"

What i did till now:

void loop(){
  int RP= 1391;
  int AP= 1581;
  int PF= 88;
  int V= 25500;
  int I= 62;
  char RPh= char(bitDividerhigh(RP));
  char RPl= char(bitDividerlow(RP));
  char APh= char(bitDividerhigh(AP));
  char APl= char(bitDividerlow(AP));
  char PFh= char(bitDividerhigh(PF));
  char PFl= char(bitDividerlow(PF));
  char Vh= char(bitDividerhigh(V));
  char Vl= char(bitDividerlow(V));
  char Ih= char(bitDividerhigh(I));
  char Il= char(bitDividerlow(I));
  Serial.write(0x7E);
  Serial.write((byte) 0x0);
  Serial.write(0x18);
  Serial.write(0x10);
  Serial.write(0x01);
  Serial.write((byte) 0x0);
  Serial.write((byte) 0x0);
  Serial.write((byte) 0x0);
  Serial.write((byte) 0x0);
  Serial.write((byte) 0x0);
  Serial.write((byte) 0x0);
  Serial.write((byte) 0x0);
  Serial.write((byte) 0x0);
  Serial.write(0xFF);
  Serial.write(0xFE);
  Serial.write((byte) 0x0);
  Serial.write((byte) 0x0);
  Serial.write(RPh);// issue here
  Serial.write(RPl);// issue here
  Serial.write(APh);// issue here
  Serial.write(APl);// issue here
  Serial.write(PFh);// issue here
  Serial.write(PFl);// issue here
  Serial.write(Vh);// issue here
  Serial.write(Vl);// issue here
  Serial.write(Ih);// issue here
  Serial.write(Il);// issue here
  long sum= 0x10 + 0xFF + 0xFF + 0xFF + 0xFE + RPh + RPl + APh + APl + PFh + PFl + Vh + Vl + Ih + Il;
  Serial.write( 0xFF - (sum&0xFF));  
  delay(100);
}
int bitDividerhigh(int  input){
  int b= 65280;
  int c= input&b;
  int d= c>>8;
  return d;
}
int bitDividerlow(int input){
  int e= 255;
  int f= input&e;
  return f;
}

Issue: I have indicated as comments in the code where i think, the data type i gave isn't the same as what its supposed to be. "Simply put just tell me, how to convert this integer values values into RF data that's perfectly compatible with Serial.write()??"

Note: I am from electrical background, so much programming technical talk can confuse me :sweat_smile: , please try to provide some code to solve my issue( My coding knowledge can be judged from above code, its not a copy&paste). Thank you !!!

int bitDividerhigh(int  input){
  int b= 65280;
  int c= input&b;
  int d= c>>8;
  return d;
}
int bitDividerlow(int input){
  int e= 255;
  int f= input&e;
  return f;
}

Why reinvent the wheel?
What's wrong with "lowByte" and "highByte"?

I have indicated as comments in the code where i think, the data type i gave isn't the same as what its supposed to be

I don't know what that means.
If you think you have used the wrong datatype, then you will have to fix it - the compiler will simply do what it is told to do.

First thing, i don't have coding in my curriculum and secondly, i learnt everything by myself. My hands on experience in arduino is comparably low to matlab(Machine learning and etc).

I am a hardcore electrical engineer, hardcore in the sense not just simple electric circuits. After 5 day long struggle and completely reading the Zigbee protocol and along with xbee.h+ some data handling logic i found in internet, i completed it.

I don't know that lowByte and highByte even exists, I am sorry because i never did coding seriously when i am in 8th standard? ( :stuck_out_tongue: , that's a very long time :wink: )