ThunderMusic said:
Hi,
I have a problem, I have to do this (MyUInt64 / MyOtherUInt64). the IDE
tells me that the / operator has not been overloaded for UInt64. Is there a
way I can do what I need to do?
Thanks
In VB.Net I assume? Unsigned Integers are not yet supported in VB.Net.
C# will allow you to work with unsigned Ints.
Options:
If you don't really need the values to be unsigned and signed Int64 will
work, use that instead. This is the preferred method.
If you still require the larger values that extra bit gives you, but you
don't have to use UInt64, then convert the values to Decimal format. Less
efficient than Int64, but a good alternative.
If you really need to keep them as UInt64's for whatever reason, and you
only have a few operations you need to do, then converting them temporarily
to Decimal and back is an option. For example:
Private Function UInt64Divide(ByVal Value1 As UInt64, ByVal Value2 As
UInt64) As UInt64
Dim a, b, c As Decimal
a = Convert.ToDecimal(Value1)
b = Convert.ToDecimal(Value2)
c = a \ b 'Note \ not / means Integer Division
Return Convert.ToUInt64(c)
End Function
If you really need them as UInt64's and have any reasonable amount of work
you need to do with them, then write a class in C# to handle all the things
you really need to do with them. Although take note that they are not
CLS-compliant. While you "can" work with them, it is not recommended,
especially if you expose any of them outside your class.
Gerald