vb.net - arduino vb.net 溢出 ASCII 和
问题描述
我遇到了这个问题:算术溢出操作
请问有什么问题,非常感谢
'I will read 999 ASCII chars from the serial buffer
'999 char * 255 max value of ASCII = 254,745
'For 254,745 I will need Long to handle this size
'I used Long to handle the big sum of the received data so I will not get
'summation overflow
Dim int_sum_of_packet As Long = 0
'I took the data from serial buffer and saved it into string
'string name is = str_packet_data_without_delimiter
'Get each char inside the received string
For Each ch As Char In str_packet_data_without_delimiter
'do the summation
int_sum_of_packet = int_sum_of_packet + Convert.ToByte(ch)
Next
'Now get the LSB (least significant Byte)
'Note: Long data type is 8 Bytes
Dim lsb As Byte
lsb = CByte(&H000000FF & int_sum_of_packet)
解决方案
推荐阅读
- python - 跟进期限,寻找行动项目
- c# - 为什么给定代码的输出为 1,13,3?
- java - 键盘可见时调整 DialogFragment 的大小
- r - 使用 Diffeqr 包解决 R 中的 SDE:可以设置种子吗?
- python - 你能解释一下为什么在运行多个请求时打开了很多 TCP 连接吗?
- sqlite - qt批量插入sqlite
- sql-server - 尝试通过 responseXML 从 XML 获取数据时出错
- asp.net-core - Hangfire中具有不同工作人员数量的多个队列(服务器)
- java - java中的对象数组有什么用?
- java - 如何单击在画布上实时更改其位置的元素