因此,每当我在在线编译器中运行这段代码时,它都会告诉我:
“用户代码中的异常: System.OverflowException:算术操作导致溢出. at Rextester.Program.Main(String[] args)”。
这是编译器无法理解我的等式的问题,还是我的代码的问题?
Public Sub Main(args() As string)
Dim X as Integer
Dim counter as Integer
X=5
Do
counter=counter+1
X=X+X
Loop until counter>120
Console.WriteLine("Hello, world!")
End Sub发布于 2020-02-02 06:43:20
签名整数的最大值是2147483647。如果该值溢出,则抛出异常以防止程序发生意外行为。
解决方案:为X variable使用Int64。最大值为9223372036854775807
https://stackoverflow.com/questions/60023728
复制相似问题