So either Math.ceil is not pristine and was replaced with some unexpected code or your call of Math.ceil is using the wrong characters. For example 1 instead of l or с instead of c etc. Try to retype it manually. Try to enter Math.ceil in the browser's console and inspect what it returns.

Answer from falinsky on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › ceil
Math.ceil() - JavaScript | MDN
Because ceil() is a static method of Math, you always use it as Math.ceil(), rather than as a method of a Math object you created (Math is not a constructor).
🌐
Reddit
reddit.com › r/c_programming › ceil() function is not working
r/C_Programming on Reddit: ceil() function is not working
January 6, 2022 -

I have included the math.h header file but ceil() and floor() functions are not working. But pow() function works. I have given the error below.

/usr/bin/ld: /tmp/ccnYHlT4.o: in function `main':

stuff.c:(.text+0x1f): undefined reference to `floor'

collect2: error: ld returned 1 exit status

How to fix this?

🌐
Codecademy
codecademy.com › forum_questions › 4f35e646fe0083000301a5e5
1.2: Why not use Math.ceil? | Codecademy
Whereas floor returns the largest integer LESS THAN or equal to a number. Just test it yourself in the Scratchpad with something like this: console.log(Math.floor(52.59)); console.log(Math.ceil(52.59));
🌐
SketchUp Community
forums.sketchup.com › dynamic components
Math Function "CEILING (number, significance)" does not work properly? - Dynamic Components - SketchUp Community
January 24, 2015 - Math Function “CEILING (number, significance)” does not work properly? Example 1: CELING (-1.24) value is changed to “2” (and should be “-1”) Example 2: CELING (-1.24, .1) the value changes to “-1.3” (and should be “-1.2”) in my opinion for example, the function “FLOOR (number, significance)” - is working properly.
🌐
GitHub
github.com › CalderaWP › Caldera-Forms › issues › 2555
Uncaught ReferenceError: ceil is not defined · Issue #2555 · CalderaWP/Caldera-Forms
April 19, 2018 - Calculation using ceil (Math.ceil) doesn't appear to work like other Math functions ·
Published   May 25, 2018
Author   SilvorMike
Top answer
1 of 3
28

This is probably because when you divide an Integer by an Integer you get an Integer back which has the same value as Decimal.round(RoundingMode.DOWN).

system.assertEquals(1, 8/5);
system.assertEquals(8/5, (8.0/5).round(RoundingMode.DOWN);

system.assertEquals(-1, -8/5);
system.assertEquals(-8/5, (-8.0/5).round(RoundingMode.DOWN);

system.assertEquals(2, 7/3);
system.assertEquals(7/3, (7.0/3).round(RoundingMode.DOWN);

If you know you have Integers and you want to get their ceiling, you could do something like:

public static Integer ceiling(Integer x, Integer y)
{
    return Math.ceil(Decimal.valueOf(x).divide(y, /*digits*/ 1));
}
2 of 3
17

Integer Division

In Apex Code, similar to Java, when there are two like numeric data types (e.g. both Integers), then they are calculated in a way that returns the same data type. Integers cannot store fractions, so when you do something like 7/3, the fraction is silently discarded. As far as I know, integer division works in the same for every programming language in the world where the result of integer arithmetic is an integer.In many languages where the result of two integers being divided together results in an integer, the fraction is often dropped entirely, although exceptions do exist (some perform rounding, instead).

Parameter Promotion

You'll notice that there's no function Math.ceil that accepts an Integer. This means if you give it an integer, it will implicitly be cast to a floating point value before being processed by Math.ceil.

Arithmetic Promotion

When two numbers are operated on using the standard operators (+, -, /, *), if one of those parameters are a floating point value, the other one will also automatically become a floating point value. Similarly, if a integer and a long were involved in an operation, both numbers become long, and the return type becomes long. So, the goal is to create a situation where a floating point is returned. For example, this results in the correct result:

Integer x = Math.ceil(7.0/3).intValue();

Here, the 7.0 indicates a floating point operation. You'd also get the same effect if you did this:

Decimal x = 7;
Integer y = 3;
Integer z = Math.ceil(x/y).intValue();

This behavior is well-defined, and mimics the behavior in Java. You can read more about automatic widening conversion in the Java documentation, as well as rules about integer division. You'll find that, while not explicitly mentioned in the Apex Code Developer's Guide (as far as I can tell), it obeys the same rules.

Find elsewhere
🌐
W3Schools
w3schools.com › jsref › jsref_ceil.asp
JavaScript Math ceil() Method
Math.ceil() is an ECMAScript1 (JavaScript 1997) feature.
🌐
Sololearn
sololearn.com › en › Discuss › 2411707 › why-is-mathceil-function-malfunctioning-in-code-coach-section
Why is Math.ceil function malfunctioning in code coach section... | Sololearn: Learn to code for FREE!
Thanks Jayakrishna🇮🇳 ... Math.ceil requires double parameters ... Aaron 5/2 result 2 because both integers. If you want to get decimal point value, you need to have atleast one float or double value.. as 5.0/2 or 5/2.0 then you get 2.5 ...
🌐
Wikipedia
en.wikipedia.org › wiki › Floor_and_ceiling_functions
Floor and ceiling functions - Wikipedia
February 5, 2026 - In most programming languages, the simplest method to convert a floating point number to an integer does not do floor or ceiling, but truncation. The reason for this is historical, as the first machines used ones' complement and truncation was ...
🌐
Cppreference
en.cppreference.com › w › cpp › numeric › math › ceil.html
std::ceil, std::ceilf, std::ceill - cppreference.com
The library provides overloads of std::ceil for all cv-unqualified floating-point types as the type of the parameter.(since C++23) If no errors occur, the smallest integer value not less than num, that is ⌈num⌉, is returned. ... Errors are reported as specified in math_errhandling.
🌐
Codecademy
codecademy.com › forum_questions › 4f977513839b6d0003005464
2.1 Is there some reason no one uses Math.ceil? | Codecademy
Math.random() returns a random float between 0 and 1, *10 makes it between 0 and 10(not inclusive!), add 1 to make it between 1 and 11, which is floor()ed to an integer between 1 and 10(inclusive) ... The reason is that Math.random() returns a number that is greater than or equal to 0 but strictly less than 1. So your example of Math.ceil(Math.random() * 10) would actually return a number between 0 and 10, not what we want.
🌐
Codecademy
codecademy.com › forum_questions › 4f2326510884e8000100e919
Is there a reason Math.ceil was not used instead of Math.floor? | Codecademy
If you really want to use Math.ceil you need to avoid the zero case from the random number generator. This is possible by first subtracting the random value from 1 and multiplying by 6. ... Note that this will not produce the same sequence as ...
🌐
O'Reilly
oreilly.com › library › view › javascript-the-definitive › 0596101996 › re106.html
Math.ceil( ): round a number up — ECMAScript v1 - JavaScript: The Definitive Guide, 5th Edition [Book]
August 17, 2006 - Math.ceil( ) computes the ceiling function—i.e., it returns the closest integer value that is greater than or equal to the function argument. Math.ceil( ) differs from Math.round( ) in that it always rounds up, rather than rounding up or down ...
Author   David Flanagan
Published   2006
Pages   1018