-
Special Member
best way to convert a negative number to positive?
umm.. hehe.. simply need the easiest way to turn negative numbers into positive..
i remeber my algebra teacher telling me that if you multiply postive one (+1) with any negative number, the number will become positive..
however this doesnt seem to be the case with flash..
real life:
10 * 1 = 10
-10 * 1 = 10
in flash
10 *1 = 10
-10 * 1 = -10
-
Shoot your teacher or eat more ginsing...
Multiply two negatives and you will get a positive.
-10 * -1 = 10
-
Special Member
Shoot your teacher or eat more ginsing...
Multiply two negatives and you will get a positive.
-10 * -1 = 10
lol. i think i neeed to eat more ginseng.. my bad.. ..guess it's not good to do math around 3 am in the morning and you're sleepy as heck. lol
but anyway, i just went ahead and did a condition :
if(curDifference >100){
blur.blurX = 100;
}else{
blur.blurX = curDifference;
}
for code optimizational reasons I was hoping to have a SINGLE LINE of mathematical code to keep my value POSITIVE.. but i guess a simple condition doesnt make much of a difference.
thanks....for the ginseng suggestion too .lol
-
Not a problem, I had to call up my sister once, she's a math teacher, to remember what they called one of these --> )
A parenthesis! And I can't stand the taste of ginseng
-
Special Member
lol...
we all get stupeed at times.. thanks
-
Bearded (M|G)od
here is your 1 line solution:
Code:
var mynumber = -10;
mynumber = (mynumber<0) ? (-mynumber) : mynumber;
trace(mynumber); //traces 10
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|