Forum Discussion
Mike_Thompson_9
Nimbostratus
Aug 08, 2007CommonULong64 OverflowException
I am trying to convert the CommonULong64 type to UInt64 in .NET for a CommonStatistic type. Sometimes this works fine and I get a good number back. Other times I get a System.OverflowException. The...
Aug 09, 2007
I've been working on this as well and have been having the same issues as you have. Any time a conversion from your -176378626 to a unsigned integer is causing an overflow. -176378626 should equate to 4118588670 as a unsigned 32 bit value but it seems however I try, I can't get VB to do that conversion. C handle it fine with it's dynamic casting, but for some reason VB keeps overflowing.
I'll keep pounding, but for the life of me I can't get VB do do the conversion. For reference, This is what should be the true values
high = 4, low = -176378626 (4118588670)
val = (high << 32) | low
high << 32 -> 0x0000000400000000
low -> 0x00000000F57CACFE
value64 -> 0x00000004F57CACFE
value64 -> 18446744073533172990
Just as an aside, you cannot convert -1 into a unsigned number it seems:
Dim ui64 As UInt32 = Convert.ToUInt32(-1)
The value should be 4294967295 but it results in an overflow exception.
If anyone out there understands the insides of VB's type system enough to make sense out of this, if you would please chime in, we'd really appreciate it.
Any chance on writing the method that does the conversion in C?
-Joe
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects