This is something really easy but my brain is struggling today. I have a long which has a value of 10. I want to convert it to negative (i.e. -10)
I am using
lValue = lValue - (lValue * 2);
There has to be a simpler bit swapping way of doing it.
This is a discussion on Convert a long to negative? within the C++ Programming forums, part of the General Programming Boards category; This is something really easy but my brain is struggling today. I have a long which has a value of ...
This is something really easy but my brain is struggling today. I have a long which has a value of 10. I want to convert it to negative (i.e. -10)
I am using
lValue = lValue - (lValue * 2);
There has to be a simpler bit swapping way of doing it.
Yeah, like:
Code:lValue = -lValue;
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
See, I said my brain had given up for the day.