[quote author="Lukas Geyer" date="1327480231"]
For the one's complement C++ has its own operator
quint8 hexval_1_complement = ~15; // 11110000(2) 240(10) F0(16)
quint8 hexval_2_complement = ~0x15; // 11101010(2) 234(10) EA(16)
[/quote]
Thank you, I understand!
Cheers for the examples as well, well appreciated.
That "Pretty much" solved my problem! I get the right values and answers now.
But I'v been trying to achieve this using variables.
eg
Your push a number in.. stick with 15..that is saved to a variable (An integer)
Int Number= 15;
quint8 hexval_2_complement = ~0x(Number);
That is invalid and does not work (Being Int shouldnt affect?, but replacing with 15 will produce 234, thus can be converted to EA.
I CAN do
quint8 hexval_1_complement = ~Number; // 11110000(2) 240(10) F0(16)
But as noted above it produces 240, which isn't exactly helpful.
Sounds weird to obtain the int value then use that val as the hex val (as they dont equal each other).