Sign in to follow this  
Followers 0
victor

How to change an int from positive to negetive?

4 posts in this topic

#1 ·  Posted (edited)

How to change an int from positive to negetive?

example -4 to 4

thanks in advance

Edited by victor

Share this post


Link to post
Share on other sites



$Variable = -4

MsgBox(0, "Before Switch", "Your Variable Before Switch Is " & $Variable)

$Variable = PosNegSwitch($Variable)

MsgBox(0, "Before Switch", "Your Variable After Switch Is " & $Variable)

Func PosNegSwitch($Var)

$Var = ($Var * -1)

Return $Var

EndFunc

Share this post


Link to post
Share on other sites

thanks

Share this post


Link to post
Share on other sites

No Problem, if you knew some basic Algebra you would know any number times -1 will result in the oposite signs of the same number.

For example:

5 x -1 = -5

-5 x -1 = --5(Which two negitives make positive) = +5 or 5

Very simple, you just had to reorganize it into a variable line. B)

Thanks for asking your question, I'm glad I could help.

AutoIt Smith

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0