@dailow, thanks for your patience.
Subtracting 0x1000000 is actually off by one, should actually subtract 0xFFFFFF. The "proper" way would actually be watts = ((~watts) & 0xFFFFFF) * -1, but watts -= 0xFFFFFF works as well and is much cleaner. I've taken the liberty of expanding the logic a bit so it will handle both of the most common ways of expressing negative numbers.
@dailow, thanks for your patience. Subtracting 0x1000000 is actually off by one, should actually subtract 0xFFFFFF. The "proper" way would actually be
watts = ((~watts) & 0xFFFFFF) * -1
, butwatts -= 0xFFFFFF
works as well and is much cleaner. I've taken the liberty of expanding the logic a bit so it will handle both of the most common ways of expressing negative numbers.