Ceil v0.1.0

Source
Rounds up to the nearest integer value.

Package: Math

Signature

func Ceil(x: float64) -> float64;
func Ceil(x: float32) -> float32;

Parameters

NameTypeDescription
xfloat64 / float32The value to round.

Returns

The smallest integer value at or above x, still represented as a floating-point number. Ceil(-0.5) is -0.0 rather than 0.0 — truncation carries the sign of x across, and IEEE-754 asks for that sign to survive. A NaN passes through unchanged.

Example

import Math::Ceil;

func Main() -> int {
    let a = Ceil(3.2);  // 4.0
    let b = Ceil(-3.7); // -3.0
    return 0;
}

See also

  • Math — the package overview
  • Floor — round down
  • Round — round to the nearest integer
  • Trunc — round toward zero