nickthedude nickthedude - 1 year ago 75
Objective-C Question

isn't there an operator in c to change the sign of a int float etc from negative to positive or vice versa?

trying to find absolute value and i thought there was a simple way to just invert the sign with '~' or something.

Answer Source
float newValue = oldValue * -1;


float newValue = -(oldValue); //() aren't needed, I just use them out of habit
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download