Class Ceiling
- Namespace
- YndigoBlue.Velocity.Functions
- Assembly
- YndigoBlue.Velocity.dll
Represents the CEILING mathematical function that rounds a number up to the nearest integer.
public class Ceiling : Function, ICheckItem, IDefaultItem, IFilterItem, IElement
- Inheritance
-
Ceiling
- Implements
Remarks
The CEILING function returns the smallest integer greater than or equal to the input value. For example, CEILING(4.3) returns 5, CEILING(-4.7) returns -4. This is useful for allocation calculations, pagination, or ensuring minimum quantities when rounding up is required.
Examples
Round each price up to the nearest whole dollar:
var schema = manager.LoadSchema("catalog");
var products = schema["products"];
var query = new Query()
.Select([ products["name"], new Expression("ceiling_price", new Ceiling(products["price"])) ])
.From(products);
var results = manager.Retrieve(query);
Use the typed Column constructor when working with a pre-resolved column variable:
var schema = manager.LoadSchema("catalog");
var products = schema["products"];
Column priceColumn = products["price"];
var query = new Query()
.Select([ products["name"], new Expression("ceiling_price", new Ceiling(priceColumn)) ])
.From(products);
var results = manager.Retrieve(query);
Round a hard-coded numeric literal up to the next integer:
// Double literal: CEILING(4.3) → 5
var ceilDouble = new Ceiling(4.3);
// Decimal literal: CEILING(4.1m) → 5
var ceilDecimal = new Ceiling(4.1m);
Constructors
- Ceiling(IEnumerable<IElement>)
Initializes a new instance of CEILING for multiple elements.
- Ceiling(decimal)
Initializes a new instance of CEILING for a decimal literal value.
- Ceiling(double)
Initializes a new instance of CEILING for a double literal value.
- Ceiling(IElement)
Initializes a new instance of CEILING for a single element.
- Ceiling(Column)
Initializes a new instance of CEILING for a column.