Integer functions can round off values to integers.
This can be done in different ways: upwards or downwards.
|
| Function | Description |
|---|---|
| Ceil(x) | Round towards plus infinity |
| Fix(x) | Round towards zero |
| Floor(x) | Round towards minus infinity |
| Round(x {,n}) | Round towards the nearest integer. With n you can specify the number of decimals of the resulting value. n can be a number from 0 to 9. |
'Examples of using integer functions
'Round(x) rounds towards the nearest integer
Round(3.2)
Ans = 3
Round(3.8)
Ans = 4
Round(-3.2)
Ans = -3
Round(-3.8)
Ans = -4
'You can specify the number of decimals with Round(x, n)
Pi
Ans = 3.141592654
Round(Pi)
Ans = 3
Round(Pi, 2)
Ans = 3.14
Round(Pi, 4)
Ans = 3.1416
'Ceil(x) rounds towards plus infinity
Ceil(3.2)
Ans = 4
Ceil(3.8)
Ans = 4
Ceil(-3.2)
Ans = -3
Ceil(-3.8)
Ans = -3
'Fix(x) rounds towards zero
Fix(3.2)
Ans = 3
Fix(3.8)
Ans = 3
Fix(-3.2)
Ans = -3
Fix(-3.8)
Ans = -3
'Floor(x) rounds towards minus infinity
Floor(3.2)
Ans = 3
Floor(3.8)
Ans = 3
Floor(-3.2)
Ans = -4
Floor(-3.8)
Ans = -4
'Plot a discontinuous function with the function Round(7 * Sin(x))
Plot(Round(7 * Sin(x)))
Plot done