首页 新闻 会员 周边

Int32 分成两部分,高低位如何互转。

0
悬赏园豆:5 [已解决问题] 解决于 2019-04-30 17:06

如C# Int32类型取高、低16位:Int32 num = 132073; int low = num & 0xffff; int high = num >> 16;
那如何将高、低16位low和high转成num。
1.如何互转?
2.希望给个链接关于c#高低位的

张林-布莱恩特的主页 张林-布莱恩特 | 初学一级 | 园豆:108
提问于:2019-04-19 11:14
< >
分享
最佳答案
0

private static int TwoShortConvInt(short low16Bit,short high16Bit)
{
return (high16Bit<<16) + low16Bit;
}
private static void IntConvTwoShort(int num,ref short low16Bit, ref short high16Bit)
{
high16Bit =(short)( num >> 16);
low16Bit = (short)(num &short.MaxValue);
}

张林-布莱恩特 | 初学一级 |园豆:108 | 2019-04-29 16:36

总结了一下
c#位运算实际运用
https://www.cnblogs.com/zhangmumu/p/10793689.html
c#位运算实际运用
https://www.cnblogs.com/zhangmumu/p/10781201.html

张林-布莱恩特 | 园豆:108 (初学一级) | 2019-05-01 23:28
其他回答(1)
0
Convert.ToInt32();
Convert.ToInt16();
Convert.ToInt64();

https://zzk.cnblogs.com/s/blogpost?w=Int32%20Int16%20Int64%20C%23

收获园豆:5
Shendu.CC | 园豆:2138 (老鸟四级) | 2019-04-19 14:05

不是这样的,位操作,已经解决了

支持(0) 反对(0) 张林-布莱恩特 | 园豆:108 (初学一级) | 2019-04-29 14:00
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册