计算9000转换成十六进制后把高低位分开赋给另外两个参数
9000的十六进制是 2328,有两个变量angle1,angle2,应该得到angle1=0x23,angle=0x28;那么怎么实现呢?
#include<stdio.h>
#include<stdlib.h>
typedef unsigned char BYTE;
int main(){
int angle = 9000;
BYTE angle1, angle2;
int tem1_angle = angle;
angle1 = BYTE(tem1_angle >> 8);
int tem2_angle = angle;
//angle2 = tem2_angle&(0xFF); 注释掉的句子可以代替其下面一句
angle2 = BYTE((tem2_angle<<24)>>24);
printf("0x%x,0x%x
",angle1 ,angle2);
return 0;
}