Hello, I am asking for help because I can't figure out how to reverse the sign of an int number.
example : int variable =-50;
example : int variable =-50;
Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tamed-ek wrote:Why a mistake? The question was about reversing the sign, not calculating the absolute value.If the variable int a; can take positive or negative values, using a=-a is an error. There is an abs() function and its use is a must.
a=abs(a);
Marcin_xx1 wrote:Then keep int tenths of degrees instead of units and only convert before displaying.I wanted to have the result with tenths, but when the measurement variable is declared as float or double, it eats up too much space in the code, maybe there is another solution?