|
| 1 | +# int.ceil |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +## Syntax & Usage |
| 6 | + |
| 7 | +> [!NOTE] |
| 8 | +This function returns the smallest integer value of the given number.\ |
| 9 | +**When inputting negative numbers, the function will behave oppositely (ceil -> floor).** |
| 10 | + |
| 11 | +```lua |
| 12 | +function int.ceil(x) -- Returns the smallest integer greater than or equal to `x`. |
| 13 | +``` |
| 14 | + |
| 15 | +| Parameter | Type | Description | |
| 16 | +| :-------: | :------------------------------------ | :------------------------------------------ | |
| 17 | +| x | [**int object**](type.intobj.md) only | Required. The value to be processed. | |
| 18 | + |
| 19 | +**Return Value:** |
| 20 | + |
| 21 | +1. [**int object**](type.intobj.md) |
| 22 | + |
| 23 | +**Example:** |
| 24 | + |
| 25 | +```lua |
| 26 | +local int = require("int") -- import module |
| 27 | + |
| 28 | +local x, y = int.new("-12.2", "12.3456") |
| 29 | +print(int.ceil(x)) -- output: -12 |
| 30 | +print(int.ceil(y)) -- output: 13 |
| 31 | +``` |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## methods |
| 36 | + |
| 37 | +This feature lets you to call functions on an object. |
| 38 | + |
| 39 | +```lua |
| 40 | +local int = require("int") -- import module |
| 41 | + |
| 42 | +local x, y = int.new("-12.2", "12.3456") |
| 43 | +print(x:ceil()) -- output: -12 |
| 44 | +print(y:ceil()) -- output: 13 |
| 45 | +``` |
| 46 | + |
| 47 | +> [!TIP] |
| 48 | +In this example, a function inside the object is called and returns the object itself as the input. |
| 49 | + |
| 50 | +also you can do like this: |
| 51 | + |
| 52 | +```lua |
| 53 | +local int = require("int") -- import module |
| 54 | + |
| 55 | +local x, y = int.new("-12.2", "12.3456") |
| 56 | + |
| 57 | +-- this works like "print(int.ceil(x))" |
| 58 | +print(y.ceil(x)) -- output: -12 |
| 59 | + |
| 60 | +-- this works like "print(int.ceil(y))" |
| 61 | +print(x.ceil(y, 2)) -- output: 13 |
| 62 | +``` |
| 63 | + |
| 64 | +> [!TIP] |
| 65 | +In this example, a function inside the object is called but a different object is used as the input. |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +[**function & methods**](../README.md#function--methods) |
| 70 | + |
| 71 | + |
0 commit comments