I'm trying to transfer a C# function to C++ but ran into a lovely problem I've never seen nor needed before. Everything has transfer quite nicely except for a bit shift line.
C# - Works without problems.
long val = 2791804260201463808;
int Cap = (int)val; //-608501760
val = (long)((ulong)val >> 32);
return val; // this returns 650017582
Now transfer to C++
C++ - Compile error "warning C4293: '>>': shift count negative or too big, undefined behavior"
long val = 2791804260201463808;
int Cap = (int)val; //-608501760
val = (long)((ulong)val >> 32);
return val; // this returns -608501760 - No change, as if bit shift was skipped
How can I transfer this? I'm having a problem seeing out of my box.
I've tried different variable types with no luck.