YesNoOk
avatar

Abs (math) (Triggers) (Read 6410 times)

Started by JustNoPoint, September 09, 2015, 05:59:38 pm
Share this topic:
Abs (math) (Triggers)
New #1  September 09, 2015, 05:59:38 pm
  • ******
    • www.justnopoint.com/
Computes the absolute value of its argument.

Format:
abs(exprn)
Arguments:
exprn
Expression to compute the absolute value of.
Return type:
Same as the type of exprn.
Error conditions:
Returns bottom if exprn evaluates to bottom.
Last Edit: September 18, 2015, 02:56:28 pm by Just No Point
Re: Abs (math) (Triggers)
#2  September 09, 2015, 06:45:12 pm
  • ****
  • A frame here, a pixel there.
So, if you have an expression whose result could end up being negative or positive, using this will return the positive equivalent if it turns out to be negative? I was just thinking the other day about how to improve my Akuma's hitspark placement code, and was wondering if Mugen had something like this. It should come in handy.
Re: Abs (math) (Triggers)
#3  September 09, 2015, 06:59:07 pm
  • ******
    • www.justnopoint.com/
@cybaster:
@Rajaaboy:
@xgargoyle:
Just tagged the top 3 math guys off the top of my head to better answer.
I enjoy posting these because I read them and try to absorb them as I do.
And I see it helps to bring a bit of spotlight on each too.

I was a bit unsure exactly what this meant so I'm glad it's getting some clarification! Math isn't a strong point of mine.
Re: Abs (math) (Triggers)
#4  September 09, 2015, 07:04:01 pm
  • ****
  • Target Acquired.
    • Ukraine
    • mugencoder.com
I think the easiest way to describe abs() is that whatever value/expression you pass to it as a parameter will always have a positive result.

Code:
abs(-1) = 1
abs(1) = 1

-[Все слова это только слова.]-
Re: Abs (math) (Triggers)
#5  September 09, 2015, 07:12:52 pm
  • ******
  • 90's Kawaii
  • :thinking:
    • Guatemala

  • Online
felineki link=topic=168972.msg2160024#msg2160024 date=
112 said:
So, if you have an expression whose result could end up being negative or positive, using this will return the positive equivalent if it turns out to be negative?
Yeah. Useful to avoid negative roots and negative distances. Useful if you want a V shaped costellation of explods, too.
Re: Abs (math) (Triggers)
#6  September 09, 2015, 08:14:03 pm
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
You should tag Bia as well, she's the best at math stuff.

There's not much that can be said from abs(), it basically removes the sign of any number.
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: Abs (math) (Triggers)
#7  September 10, 2015, 07:11:30 am
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
So, if you have an expression whose result could end up being negative or positive, using this will return the positive equivalent if it turns out to be negative?

Precisely.  I've been using Abs() a lot lately due to how useful it is.

Re: Abs (math) (Triggers)
#8  September 10, 2015, 07:31:47 am
  • ****
  • Still lurks regularly, but posts once a blue moon
    • Canada
Yup, Abs() is essentially the equivalent of using the absolute value symbols |x| in mathematics.
Re: Abs (math) (Triggers)
#9  September 10, 2015, 10:14:57 am
  • ****
  • play more SNK games
  • I FUCKING LOVE PLATINUM!
    • South Africa
    • www.trinitymugen.net/
Using -abs will ensure that said number is always negative on the other hand