本文介绍了VB.NET中的有符号和无符号变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过移位来进行转换。如下所示代码

I need to do a conversion by shifting bits. As you see this below code

        Dim x As Integer = (&H2 << 8) Or &HCC
        Me.Text = x

它显示716这是正确的。但是对于这种转换:

It shows me 716 which is correct. However for this conversion:

        Dim x As Integer = (&HFF << 8) Or &HFC
        Me.Text = x




而不是-4它显示65532这是正确的。但是,在VB.NET中的数值系统是完全正确的,因为它与第一个负位无关。为解决这个问题你有什么建议?


Instead of -4 it shows me 65532 which is in correct. However, in numerical system in VB.NET is completely correct because it is not related to first negative bit. for Solving this problem what do you suggest?

推荐答案

Dim x
As
=(& HFFS<< 8)
& HFC


这篇关于VB.NET中的有符号和无符号变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 15:40