JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

C# modbus RTU 中使用到的 ushort[] 转 int 与 int 转 ushort[]

发布时间 2023-08-02 13:06:07作者: 威流
        public static int ushorts2int(ushort[] res)
        {
            int high = res[0];
            int low = res[1];
            int value = (high << 16) + low;
            return value;
        }

        public static ushort[] int2ushorts(int res)
        {
            ushort ust1 = (ushort)(res >> 16);
            ushort ust2 = (ushort)res;
            return new ushort[] { ust1, ust2 };
        }

 

    本栏目推荐文章
  • c++编译OpenSceneGraph-3.4 出现 error: narrowing conversion of ‘-1’ from ‘int’ to ‘char’ inside { } [-Wnarrowing]
  • C语言中这几种数组,弄明白了吗?int(*pai[2])[5],int *aapi[2][2], int **p[2], int *numT[5], int(*num2)[5]
  • 232Modbus转Profinet应用案例分享
  • C语言int * (* (*fp1) (int) ) [10]声明是啥意思呢?
  • C/C++函数参数声明解析:int fun() 与 int fun(void) 的差异揭秘
  • QT6.4.3中,关于QString asprintf(const char*cformat,...)与int asprintf(char**strp,const char*fmt,...)的使用问题
  • Modbus转Profinet网关揭秘
  • __int128
  • 分享C#做modbus开发的几个坑
  • Modbus以及上位机软件实际运用
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们