S
Simon Devlin
Hi folks,
I've been bashing my head against this all afternoon and am now totally
baffled.
Given this (a simple routine to turn a ip address string into an decimal)
<snip>
Dim Parts(3) as string ' --> each element is an integer in the range 0-255
Dim Big as int64 = 0
Big =16777216 * cint(Parts(0))
Big = big + (65536 * cint(Parts(1)))
big = big + (256 * cint(parts(2)))
big = big + cint(parts(3))
I get arithmetic overflow errors on execution (at the first line).
Interestingly if I play around with constants then by doing
big = 16777216 * 255
The IDE reports "Constant expression not representable in type integer".
This doesn't make a whole lot of sense given that big is declared as an
int64. Values greater than 127 result in the same - clearly suggesting an
overflow somewhere, but these numbers are well within the scope of an int64
(ordinarilly a uint32 is sufficient)
Does anyone have any suggestions to stop me going mad. I'm not that
experienced VB.NET / ASP.NET, so hopefully I'm missing something really
obvious.
Thanks
I've been bashing my head against this all afternoon and am now totally
baffled.
Given this (a simple routine to turn a ip address string into an decimal)
<snip>
Dim Parts(3) as string ' --> each element is an integer in the range 0-255
Dim Big as int64 = 0
Big =16777216 * cint(Parts(0))
Big = big + (65536 * cint(Parts(1)))
big = big + (256 * cint(parts(2)))
big = big + cint(parts(3))
I get arithmetic overflow errors on execution (at the first line).
Interestingly if I play around with constants then by doing
big = 16777216 * 255
The IDE reports "Constant expression not representable in type integer".
This doesn't make a whole lot of sense given that big is declared as an
int64. Values greater than 127 result in the same - clearly suggesting an
overflow somewhere, but these numbers are well within the scope of an int64
(ordinarilly a uint32 is sufficient)
Does anyone have any suggestions to stop me going mad. I'm not that
experienced VB.NET / ASP.NET, so hopefully I'm missing something really
obvious.
Thanks