I
I
imggprog2020-10-11 17:49:00
C++ / C#
imggprog, 2020-10-11 17:49:00

Is there a method in c# that returns the number that was sent to it but with a minus sign?

If not, please advise how this can be done.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
GavriKos, 2020-10-11
@imggprog

int Minus (int input)
{
return Math.Abs(input)*-1;
}

This is if you want the negative to remain negative. And if you just invert the sign - so multiply by -1.

H
HemulGM, 2020-10-11
@HemulGM

-MyNumber

D
Dmitry Pavlov, 2020-10-11
@Stalker31

int Minus(int i){
if(i>0)
 return -1*i;
else return i;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question