You can just multiply by 100, take the ceiling of that new number (32131.125 => 32132), then divide that by 100.

var x = 321.31125
console.log(Math.ceil(x * 100) / 100)

Edit: If you are looking to create a function, you could always do something like this post details:

function roundUp(num, precision) {
    precision = Math.pow(10, precision)
    return Math.ceil(num * precision) / precision
}

console.log(roundUp(321.31125, 2));

Answer from Nick G on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › ceil
Math.ceil() - JavaScript | MDN
The Math.ceil() static method always rounds up and returns the smallest integer greater than or equal to a given number.
🌐
W3Schools
w3schools.com › jsref › jsref_ceil.asp
W3Schools.com
The Math.ceil() method rounds a number rounded UP to the nearest integer.
Discussions

How to get the ceil value after 2 decimal places using JavaScript - Stack Overflow
I want to achieve the following: suppose x = 321.31125 Now I want the ceil value after the 2nd decimal point ... so the expected result should be 321.32 Note: I know rounding which will return 3... More on stackoverflow.com
🌐 stackoverflow.com
Newbie here. Is using Math.ceil(Math.random()) a bad idea?
As spamhammer alludes to (but to which he gives the wrong results), the distributions will in fact be different. First, we note that Math.random() returns values in the range of [0,1). That means it includes 0, but doesn't include 1. See here . The first expression thus gives you values in the range [1, n) with a uniform distribution. So it includes 1, but not n. The second expression (yours) gives you values in that same range of [1,n) plus an additional, almost infinitesimally small chance to get a value of 0. Think about it: if Math.random() returns 0, multiplying by n also gives 0. Then taking the ceiling of that value still gives you 0. This is probably why the books give you the first expression. So no, the two expressions are not equivalent, and the first one is the correct one you want to use. More on reddit.com
🌐 r/javascript
16
0
January 19, 2012
Why not always use Math.round instead of Math.floor?

Well, they are two different functions, with two different uses. Math.floor() always rounds down to the nearest integer, while Math.round() will round up or down depending on what side of .5 the number falls on. So, the basic answer is that you use which one gets the result you expect.

When it comes to generating random numbers though, Math.floor() has a more even distribution than Math.round(). If you want to generate a random number between 0 and 2, take the following examples:

Math.floor(Math.random() * 3). Here, 0-0.999999 will give you 0, 1.0 to 1.999999 will give you 1, and 2.0 to 2.999999 will give you 2. Every number has a 33% chance of being the result.

Math.round(Math.random() * 2). Here, 0-0.499999 will give you 0, 0.5 to 1.499999 will give you 1, and 1.5 to 1.999999 will give you 2. Note that the range of numbers that lead to a 1 is twice as big as those that lead to 0 or 1. That is 25% chance of 0, 50% chance of 1, and 25% chance of 2.

More on reddit.com
🌐 r/javascript
13
1
January 8, 2016
Math.floor vs Math.round vs parseInt vs Bitwise jsPerf
What I find interesting is how fast the bitwise stuff is--Crockford said something about not using them in The Good Parts™ because they are so slow. More on reddit.com
🌐 r/javascript
31
21
July 18, 2012
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Math › ceil
JavaScript Math ceil() - Round Up Value | Vultr Docs
November 29, 2024 - The Math.ceil() function in JavaScript is crucial when you need to round a number up to the nearest integer, regardless of whether the decimal part is small or large.
🌐
Khan Academy
khanacademy.org › computer-programming › new › pjs
Khan Academy
We cannot provide a description for this page right now
🌐
Educative
educative.io › answers › mathceil-mathfloor-and-mathround-in-javascript
Math.ceil, Math.floor, and Math.round in JavaScript
The Math.ceil function in JavaScript is used to round up a number that is passed into it to its nearest integer. What do I mean by rounding up? I mean towards the greater value. Math.ceil() only takes one parameter, the value to be rounded.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-math-ceil-method
JavaScript Math ceil() Method - GeeksforGeeks
July 15, 2024 - JS Tutorial · Web Tutorial · ... : 15 Jul, 2024 · The JavaScript Math.ceil method is used to return the smallest integer greater than or equal to a given number....
🌐
TutorialsPoint
tutorialspoint.com › javascript › math_ceil.htm
JavaScript Math.ceil() Method
The JavaScript Math.ceil() method accepts a numeric value as a parameter and rounds it UP to the smallest integer greater than or equal to that number. For instance, if we pass a numeric value "7.20" to this method, it rounds it to "8" because it is
🌐
VR Soft Tech
vrsofttech.com › javascript › javascript-math-ceil
JavaScript Math.ceil() | vrsofttech
JS - Quiz · The Math.ceil(x) method used to returns the rounded up number to the nearest integer. Syntax Copy · Math.ceil(x) Here, ceil() is a static method. Hence, we use it as Math.ceil(). Parameters · x - (Required).A number. Return Value · Number - The value of x rounding UP to the ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-math-ceil-function
JavaScript Math.ceil( ) function - GeeksforGeeks
September 9, 2024 - JS Tutorial · Web Tutorial · A to Z Guide · Projects · OOP · DOM · Set · Map · Math · Number · Boolean · Exercise · Last Updated : 9 Sep, 2024 · The JavaScript Math.ceil() function rounds a given number up to the nearest integer.
🌐
Programiz
programiz.com › javascript › library › math › ceil
JavaScript Math ceil()
The ceil() method rounds a decimal number up to the next largest integer and returns it. That is, 4.3 will be rounded to 5 (next largest integer). let number = Math.ceil(4.3); console.log(number); // Output: 5
🌐
Naukri
naukri.com › code360 › library › math-ceil
Math Ceil - Naukri Code 360
November 21, 2024 - Almost there... just a few more seconds
🌐
Math.js
mathjs.org › docs › reference › functions › ceil.html
math.js
math.ceil(c, 1) // returns Complex 3.3 - 2.7i const unit = math.unit('3.241 cm') const cm = math.unit('cm') const mm = math.unit('mm') math.ceil(unit, 1, cm) // returns Unit 3.3 cm ... math.ceil(unit, 1, mm) // returns Unit 32.5 mm math.ceil([3.2, 3.8, -4.7]) // returns Array [4, 4, -4] math.ceil([3.21, 3.82, -4.71], 1) // returns Array [3.3, 3.9, -4.7] floor, fix, round · mathjs.org • copyright © 2013-2026 jos de jong • background by waseem dahman
🌐
Amyuni
amyuni.com › WebHelp › JavaScript_SDK › math › Methods › Math_ceil.htm
Math.ceil
The ceil method rounds a number upwards to the nearest integer. ... Returns the the nearest integer when rounding upwards. Member of Math.
🌐
W3Schools
w3schools.com › python › ref_math_ceil.asp
Python math.ceil() Method
The math.ceil() method rounds a number UP to the nearest integer, if necessary, and returns the result.
🌐
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 - NameMath.ceil( ): round a number up — ECMAScript v1SynopsisMath.ceil(x)Arguments x Any numeric value or expression.ReturnsThe closest integer greater than or equal to... - Selection from JavaScript: The Definitive Guide, 5th Edition [Book]
Author   David Flanagan
Published   2006
Pages   1018
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › random
Math.random() - JavaScript | MDN
js · function getRandomInt(min, max) { const minCeiled = Math.ceil(min); const maxFloored = Math.floor(max); return Math.floor(Math.random() * (maxFloored - minCeiled) + minCeiled); // The maximum is exclusive and the minimum is inclusive } Note: It might be tempting to use Math.round() to accomplish that, but doing so would cause your random numbers to follow a non-uniform distribution, which may not be acceptable for your needs.
🌐
Accolades Dev
blog.accolades.dev › home › web-development and seo › math.ceil()in javascript
Math.ceil()in Javascript
April 14, 2023 - Math.ceil() rounds up decimal numbers to the nearest integer in JavacsriptS, useful for precise number manipulation.