Page 1 of 1

Absolute value, aka modulus

Posted: 03 Nov 2012 11:19
by Marco
Am I missing something or there really isn't a function that, given a number, returns the modulus of a number?

Re: Absolute value, aka modulus

Posted: 03 Nov 2012 11:39
by admin

Re: Absolute value, aka modulus

Posted: 03 Nov 2012 11:44
by Marco
Ditto, man!
My scenario would be

Code: Select all

|a - b| < c
I know I could square both sides, so to get positive numbers, but I don't know if it is the correct way performance-wise.
EDIT:

Code: Select all

v11.70.0105 - 2012-11-03 12:04
    + Scripting got a new function.
      Name:   Abs
      Action: Returns the absolute value of number.
      Syntax: abs(number)
        number:   Must be a number. A string will raise an error.
      Examples:
        echo abs(1);  // 1
        echo abs(0);  // 0
        echo abs(-1); // 1
        echo abs(-2.3456); // 2.3456
The quickest addition I've ever seen! Thank you Don! :appl: :appl: :appl: