Return the integer or fractional portion of a numeric expression.
n = Ceil(x)
n = Floor(x)
n = Fix(x)
n = Int(x)
n = Trunc(x)
f = Frac(x)
f | : floating point variable |
x | : any numeric variable |
n | : integer |
Ceil rounds up x to the next largest integer, while Floor rounds it down to the next smallest integer.
Trunc removes the fractional element of x and returns the integer, while Frac does the opposite and returns the fraction.
Finally, Int acts like Floor and rounds x down, while Fix is synonymous with Trunc and simply returns its integer element.
Debug.Show
Debug "-- With Positive Numbers --"
Trace Ceil(3.4) // Output: 4
Trace Floor(3.4) // Output: 3
Trace Trunc(3.4) // Output: 3
Trace Frac(3.4) // Output: 0.4
Trace Int(3.4) // Output: 3
Trace Fix(3.4) // Output: 3
Debug
Debug "-- With Negative Numbers --"
Trace Ceil(-3.4) // Output: -3
Trace Floor(-3.4) // Output: -4
Trace Trunc(-3.4) // Output: -3
Trace Frac(-3.4) // Output: -0.4
Trace Int(-3.4) // Output: -4
Trace Fix(-3.4) // Output: -3
CInt, or any of the integer Cxxx functions, acts differently to Int as it rounds the passed number to the nearest integer, as does Round.
CInt, FRound(), QRound(), Round()
{Created by Sjouke Hamstra; Last updated: 24/05/2020 by James Gaite}