B
Brians256
Why is it not possible to use bit-wise operators on 32-
bit unsigned integers? Isn't that a bit backwards? How
else can you specify a full 32-bits?
I'm trying to use some C code by translating it to C#.
However, it appears that I must either suffer a
performance hit by moving to 64-bit integers or stuff the
algorithms into a DLL via another more sane language.
Consider this C code:
int foo(void)
{
int i = 0x81234567;
int j = i >> 1;
return (j & ~i);
}
You can't do that easily in C#. A System.Int32 type
cannot contain 0x80000000 or larger value. However, a
System.UInt32 type will not allow bitwise operators.
Is Microsoft insane, or have they restricted the UInt32
type for some good reason? Hopefully I am missing
something simple, so I can port my hashing function to C#.
bit unsigned integers? Isn't that a bit backwards? How
else can you specify a full 32-bits?
I'm trying to use some C code by translating it to C#.
However, it appears that I must either suffer a
performance hit by moving to 64-bit integers or stuff the
algorithms into a DLL via another more sane language.
Consider this C code:
int foo(void)
{
int i = 0x81234567;
int j = i >> 1;
return (j & ~i);
}
You can't do that easily in C#. A System.Int32 type
cannot contain 0x80000000 or larger value. However, a
System.UInt32 type will not allow bitwise operators.
Is Microsoft insane, or have they restricted the UInt32
type for some good reason? Hopefully I am missing
something simple, so I can port my hashing function to C#.