gpt4 book ai didi

vb.net - 如何在 ULong 上使用按位运算设置大常数?

转载 作者:行者123 更新时间:2023-12-04 23:33:06 24 4
gpt4 key购买 nike

这很好用:

Public Const test As ULong = 1 << 30

这不能很好地工作:
Public Const test As ULong = 1 << 31

它会产生此错误:

Constant expression not representable in type 'ULong'



我如何使它工作?

这确实有效:
Public Const test As Long = 1 << 31

但我必须使用 优龙 .

最佳答案

您不能换档 1 << 31使用 Long 数据类型,因此您会收到此错误。

然而,这是因为1 ,作为整数文字,被视为 Int32,这是默认的整数文字。

您应该通过将其定义为:

Public Const test As ULong = 1UL << 30
Public Const test2 As ULong = 1UL << 31

UL 标志表示将 1 设为 unsigned long。 See Type characters for details .

关于vb.net - 如何在 ULong 上使用按位运算设置大常数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2357492/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com