Table of Contents

Class Abs

Namespace
YndigoBlue.Velocity.Functions
Assembly
YndigoBlue.Velocity.dll

Represents the ABS (absolute value) mathematical function that returns the non-negative value of a number.

public class Abs : Function, ICheckItem, IDefaultItem, IFilterItem, IElement
Inheritance
Abs
Implements

Remarks

The ABS function calculates the absolute value, removing the sign from negative numbers while leaving positive numbers unchanged. For example, ABS(-5) returns 5, and ABS(5) returns 5. This is useful for calculating distances, differences, or magnitude values regardless of sign.

Examples

Calculate the absolute value of each account balance adjustment:

var schema = manager.LoadSchema("finance");
var adjustments = schema["adjustments"];

var query = new Query()
    .Select([ adjustments["id"], new Expression("magnitude", new Abs(adjustments["amount"])) ])
    .From(adjustments);

var results = manager.Retrieve(query);

Use the typed Column constructor when working with a pre-resolved column variable:

var schema = manager.LoadSchema("finance");
var adjustments = schema["adjustments"];
Column amountColumn = adjustments["amount"];

var query = new Query()
    .Select([ adjustments["id"], new Expression("magnitude", new Abs(amountColumn)) ])
    .From(adjustments);

var results = manager.Retrieve(query);

Compute the absolute value of a hard-coded numeric literal:

// Integer literal
var absInt = new Abs(-42);

// Double literal
var absDouble = new Abs(-3.14);

// Decimal literal
var absDecimal = new Abs(-19.99m);

Constructors

Abs(IEnumerable<IElement>)

Initializes a new instance of ABS for multiple elements.

Abs(decimal)

Initializes a new instance of ABS for a decimal literal value.

Abs(double)

Initializes a new instance of ABS for a double literal value.

Abs(int)

Initializes a new instance of ABS for an integer literal value.

Abs(IElement)

Initializes a new instance of ABS for a single element.

Abs(Column)

Initializes a new instance of ABS for a column.