I have the following code in java that I need to convert to c++ to be able to encode unsigned int.
public static int enc_uint32be( int i, byte[] dst, int di ) {
dst[di++] = (byte)((i >> 24) & 0xFF);
dst[di++] = (byte)((i >> 16) & 0xFF);
dst[di++] = (byte)((i >> 8) & 0xFF);
dst[di] = (byte)(i & 0xFF);
return 4;
}
I am a newbie to java. I trust several experts on this forum know both languages – can someone help me with the translation.
It depends on the data type that you are planning on using, but if you just change:
to
in the function declaration, then it should behave the same (and change the byte usages in the function to
unsigned charas well).