How to convert a positive integer to a negative with Delphi? I know that you could use ABS(int)to convert a negative value to a positive, but I need to convert it positive to negative.
ABS(int)
from what I know there is no function for this. You can do
if yourvariable > 0 then yourvariable := -yourvariable;
If you want to be absolutely sure to get a negative result (or zero), use
number := -abs(number)
Ehhh... , number := number * -1; , , ... @Mef Answer
number := number * -1;
EDIT: even later, but number := 0 - number;will work too ... It also just cancels the character
number := 0 - number;
Let it nbe your number and formula forn-(n*2) = -n
n
n-(n*2) = -n
Just so I think this can be solved .. in python, though
>>>num = -234 -234 >>>num *= -1 234 >>>num 234
Correct me if I am wrong