#include <cstdio>
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
int main() {
uint8_t foo = 5;
uint8_t bar = 250;
// Gives value of 11
uint8_t diff8bit = foo - bar;
uint32_t diff1 = static_cast<uint32_t>(diff8bit);
// Gives value of 4294967051
uint32_t diff2 = static_cast<uint32_t>(foo) - static_cast<uint32_t>(bar);
// Gives value of 4294967051
uint32_t diff3 = static_cast<uint32_t>(foo - bar);
printf("diff1 = %u\n", diff1);
printf("diff2 = %u\n", diff2);
printf("diff3 = %u\n", diff3);
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KCnR5cGVkZWYgdW5zaWduZWQgY2hhciB1aW50OF90Owp0eXBlZGVmIHVuc2lnbmVkIGludCB1aW50MzJfdDsKCmludCBtYWluKCkgewoJdWludDhfdCBmb28gPSA1OwogICAgdWludDhfdCBiYXIgPSAyNTA7CiAgIAogICAgLy8gR2l2ZXMgdmFsdWUgb2YgMTEKICAgIHVpbnQ4X3QgZGlmZjhiaXQgPSBmb28gLSBiYXI7CiAgICB1aW50MzJfdCBkaWZmMSA9IHN0YXRpY19jYXN0PHVpbnQzMl90PihkaWZmOGJpdCk7CgoJLy8gR2l2ZXMgdmFsdWUgb2YgNDI5NDk2NzA1MQoJdWludDMyX3QgZGlmZjIgPSBzdGF0aWNfY2FzdDx1aW50MzJfdD4oZm9vKSAtIHN0YXRpY19jYXN0PHVpbnQzMl90PihiYXIpOwoKICAgIC8vIEdpdmVzIHZhbHVlIG9mIDQyOTQ5NjcwNTEKICAgIHVpbnQzMl90IGRpZmYzID0gc3RhdGljX2Nhc3Q8dWludDMyX3Q+KGZvbyAtIGJhcik7CgkKICAgIHByaW50ZigiZGlmZjEgPSAldVxuIiwgZGlmZjEpOwogICAgcHJpbnRmKCJkaWZmMiA9ICV1XG4iLCBkaWZmMik7CglwcmludGYoImRpZmYzID0gJXVcbiIsIGRpZmYzKTsKCiAgICByZXR1cm4gMDsKfQo=