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...
Don_MacVittie_1
Aug 13, 2007Historic F5 Account
Posted By bikemike on 08/10/2007 9:26 AM
All "bashing" aside, your help has been invaluable and I cannot thank you enough! Below is the final function that resolved the issue:
Public Shared Function Build64(ByVal value As Object) As UInt64
Return (Convert.ToUInt64(value.high) << 32) Or (Convert.ToUInt64((value.low >> 16) And &HFFFF) << 16) Or Convert.ToUInt64(value.low And &HFFFF)
End Function
Hopefully this will help others in the VB world with the same problem...
Mike, looks basically good, but you have one problem... You're word-swapping the low DWORD and not the high DWORD. They both need it because of the way the CPU stores DWORDS. Just do the top in 16 bit chunks just like you did the bottom, and this should be good for any value.
Don.
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