- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
math.ceil() function in Lua programming
There are several occurrences when we want to get the ceil value of an integer to round it off and then use that value later on.
The Ceiling value of a number is the value that is rounded to the closest integer greater than or equal to that integer.
Lua provides us with a math.ceil() function that we can use to find the ceil value of a number.
Example
Let’s consider a simple example where we will make use of the math.ceil() function in Lua −
a = math.ceil(3.3) b = math.ceil(7.1) print(a) print(b)
Output
4 8
Example
It should be noted that if we try to find ceil of a number which is already the closest integer to itself, then we will get the same number as the output. Consider the example shown below −
c = math.ceil(8) print(c)
Output
8
Example
We can also pass negative numbers in the math.ceil() function as an argument.
Consider the example shown below −
d = math.ceil(-3.3) print(d)
Output
-3
- Related Articles
- table.pack() function in Lua programming
- table.unpack() function in Lua programming
- math.floor() function in Lua programming
- math.max() function in Lua programming
- math.modf() function in Lua programming
- select() function in Lua programming
- Sort function in Lua programming
- string.byte() function in Lua programming
- string.char() function in Lua programming
- string.format() function in Lua programming
- string.gsub() function in Lua programming
- string.lower() function in Lua programming
- string.upper() function in Lua programming
- io.popen() function in Lua Programming
- How to use the Insert function in Lua Programming?

Advertisements