Skip to main content Link Search Menu Expand Document (external link)

abs() : Absolute Value


On this page

Summary

Get the absolute value of a number (remove negative sign).

Signature

abs(value)

Parameters

Parameter Type Required Description
value Number Yes Number to get absolute value of

Returns

Type: Number (same type as input)

The absolute value of the input number.


Examples

Basic Usage

     <!-- Output: 5 -->
      <!-- Output: 5 -->
  <!-- Output: 3.14 -->

Calculate Difference

<p>Difference: </p>

Data:

doc.Params["model"] = new {
    actual = 95,
    expected = 100
};

Output:

<p>Difference: 5</p>

Show Variance

<p>Variance: </p>

With Conditional


  <span class="significant">Significant change</span>


Notes

  • Works with int, long, double, decimal types
  • Returns same type as input
  • abs(0) returns 0
  • Useful for calculating distances and differences

See Also