AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   negative value <---> positive value (https://forums.alliedmods.net/showthread.php?t=172484)

schmurgel1983 11-21-2011 06:21

negative value <---> positive value
 
give a other way? as
Code:

a = -13
b = a + a*2
b == 13

Code:

a = 13
b = a - a*2
b == -13


jim_yang 11-21-2011 06:24

Re: negative value <---> positive value
 
what the hell is that?
a = -b
b = -a

schmurgel1983 11-21-2011 06:27

Re: negative value <---> positive value
 
change -13 to 13 (negative value -> positive value)
change 13 to -13 (positive value -> negative value)
or 145 to -145.... etc.
don't find a native from amxx that do it.

jim_yang 11-21-2011 06:29

Re: negative value <---> positive value
 
I already told u,
b = -a;

schmurgel1983 11-21-2011 06:34

Re: negative value <---> positive value
 
dosen't understand, next mate please.

Devil259 11-21-2011 06:35

Re: negative value <---> positive value
 
or u can do

b *= -1

jim_yang 11-21-2011 06:44

Re: negative value <---> positive value
 
Quote:

Originally Posted by schmurgel1983 (Post 1600135)
dosen't understand, next mate please.

which part of that you don't understand ? Isn't it obvious ?
Code:

new a = 13;
new b = -a;

new c = -13;
new d = -c;

if you still don't understand after reading above, then check your IQ please. :)

schmurgel1983 11-21-2011 06:45

Re: negative value <---> positive value
 
Quote:

Originally Posted by jim_yang (Post 1600146)
if you still don't understand after reading above, then check your IQ please. :)

what is the problem if u explaine your shit?
Code:

a = 5 ; b *= a => 0
a = -5 ; b *= a => 0
a = 8 ; b = -a => -8
a = -8 ; b = -a => 8

thanks Devil259 for your try ^^

MyPc 11-21-2011 07:19

Re: negative value <---> positive value
 
Quote:

Originally Posted by schmurgel1983 (Post 1600147)
what is the problem if u explaine your shit?
Code:

a = 5 ; b *= a => 0
a = -5 ; b *= a => 0
a = 8 ; b = -a => -8
a = -8 ; b = -a => 8

thanks Devil259 for your try ^^

What can't you understand ? a 9 year old kid can do it simple math.

a = 13
b = -a

so b = -13

a = -13
b = -a

so b = 13

Devil259 11-21-2011 07:20

Re: negative value <---> positive value
 
By multiplying the variable by -1, you should do what he wants. (negative value <---> positive value)

a = 6

If you want to have the negative value of a in the same variable, you can do

a *= -1

a is -6 now.


All times are GMT -4. The time now is 08:28.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.