← All exercises

Absolute Value

easy

Outputs the absolute value of a numeric input.

What it teaches

Strip the sign off a number to get its magnitude. The everyday use is deviation — how far a reading sits from target when the direction does not matter, as in ABS(Setpoint - Actual) feeding a drift alarm. Unlike Sign Check, this changes the number instead of producing comparison flags.

Inputs and outputs

TagTypeDefaultDescription
In_ValueREAL-7.5Signed input value
Out_MagnitudeREALAbsolute value of the input

Required behavior

  • Out_Magnitude is the absolute value of In_Value every scan.
  • Negative inputs become positive; positive inputs pass through unchanged.
  • At exactly 0, Out_Magnitude is 0.