How do I convert a positive Integer to a negative with Delphi? I know you could use ABS(int)
to convert a negative to a positive, but I need it to convert positive to negative.
If you want to be absolutely sure to get a negative result (or zero), use
number := -abs(number)
from what I know there is no function for that. you can make
if yourvariable > 0 then
yourvariable := -yourvariable;
Ehhh... Too late but number := number * -1;
would work too, but this change the symbol of any number, negative to positive and backwards... To ensure a negative value go with @Mef Answer
EDIT: even later, but number := 0 - number;
would work too... This just reverses the symbol as well
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With