Issue with Returning 32bit Unsigned Numbers in RLP

I’m using an RLP function (EM blocks) with the Cerbuino Bee board and having issues when the RLP function returns a number greater than 0x7FFFFFF it returns a negative value. I’m trying to turn a 32bit unsigned number from this RLP function:
unsigned int MY_RLP_ FUNCTION( void **args)
{
return 0xFFFFFFFF;
}
This function returns a negative number, -1.
How do I get this RLP function to turn 4294967295 and not negative value?
Thanks

@ tdcooper33 - Did you change the calling side to be returning a uint data type? Failing that, you can also cast the result to a uint which should give you the unsigned integer value you are looking for.

I invoke the RLP function like this:
var MY_RLP_ FUNCTION_ RESULT = MY_RLP_ FUNCTION.Invoke();
When I print out result in debug window it comes out negative. It won’t let me use uint in place of var.

@ tdcooper33 - The following will do the trick


var MY_RLP_ FUNCTION_ RESULT = (uint)MY_RLP_ FUNCTION.Invoke();

The result is cast to a uint, so var will now infer the uint datatype and everything should work since the returned bit pattern is now interpreted as unsigned rather than signed.

2 Likes

That works! Thanks a bunch! :dance: