vb.net 算术运算导致溢出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4311467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Arithmetic operation resulted in an overflow
提问by Lefteris Gkinis
When i send:
当我发送:
Result = CInt(NetApiBufferFree(pBuffer))
I receive (SOME TIMES) this error:
我收到(有时)这个错误:
Arithmetic operation resulted in an overflow.
What exactly means that? and how i can resolve it?
那究竟是什么意思?我该如何解决?
回答by Abyx
It means that CInt
argument is out of range of Integer
, -0x80000000 to 0x7FFFFFFF
And it happens when NetApiBufferFree
returns an error: error codes are bigger than 0x80000000.
这意味着CInt
参数超出了Integer
-0x80000000 到 0x7FFFFFFF的范围,并且在NetApiBufferFree
返回错误时发生:错误代码大于 0x80000000。
There is no unsigned int32 type, so use CLng
instead of CInt
.
没有无符号INT32类型,所以使用CLng
的替代CInt
。
About source of error. You should find out code of error which you get: call MsgBox or log it to file, or use breakpoint. Next find its description. If it won't help you (for example error would be E_FAIL), add code to check that pBuffer
value is valid - that it wasn't modified by something, and wasn't already freed. Add logging for NetApiBuffer*
calls.
关于错误的来源。你应该找出你得到的错误代码:调用 MsgBox 或将其记录到文件中,或使用断点。接下来找到它的描述。如果它对您没有帮助(例如错误将是 E_FAIL),请添加代码以检查该pBuffer
值是否有效 - 它没有被某些东西修改,并且尚未被释放。添加NetApiBuffer*
通话记录。
回答by Chiranjeevi Bhoosarapu
Best answer is replace 'double' in place of 'Int16/Int32/Int64'
最佳答案是用“double”代替“Int16/Int32/Int64”
some times file conversion takes huge numbers.. double never has maximum range.
有时文件转换需要大量的数字..double 从来没有最大范围。