How to round a number down to hundreds?

How to round a number down to hundreds?
For example, if you have a value of 131, how do you round it to 100?
Or is there a value of 7798, how can I round it to 7700?

You will want to use some javascript in either a function node or an expression (function is probably better for this case).

There are likely cleaner solutions out there that you can copy/ paste from stack overflow but will likely all revolve around the modulus operator (%):

131 % 100 = 31 (And then 131 - 31 = 100)
231 % 100 = 31(And then 231 - 31 = 200)

Problem with the above is you would need to know how many digits the number has (i.e. if is 1000s, then needs to be %1000) - but guessing there are smarter solutions that involve the % operator (or dedicated function) on stackoverflow as a generic javascript snippet.

Hope this helps! If you do find a working snippet, would be awesome if you could post it here for other community members.


If you always round down then I guess this would work:

Math.floor(731 / 100) * 100  // 700
Math.floor(7798 / 100) * 7700  // 7700

mluhta Thanks!
its worked!

1 Like