API Reference › Math › Math.ceil
method

Math.ceil

Math.ceil(x) -> int

Takes a fixed value and returns the smallest int not less than it — rounding toward positive infinity, so Math.ceil(2.1) is 3 and Math.ceil(4.0) stays 4. Use it when you need to cover a fractional amount with whole units: how many full tiles a span touches, or how many rows a variable-height list needs.

Parameters

xthe fixed value to round up

Example

program RowsNeeded {
  const ROW_HEIGHT: fixed = 12.0

  var content_height: fixed = 30.0

  handler Layout phase Update {
    let rows = Math.ceil(content_height / ROW_HEIGHT)   # 3
  }
}
← All symbols