Math formula to round numbers to ceiling

HI, so i need to round numbers up to the nearest full integer. So for instance if my number is 1.2 it has to round up to 2. But i noticed that with the “round” formula it rounds down to the nearest integer which would be 1. But in my use case this would lead to wrong calculations.

Is there a way to round any number with decimals up to the ceiling??

Thanks.

Math.ceil(1.2)

1 Like

Thanks Dorilama, i was hoping i could be done with formulas from weweb themselves. This looks easy enough to do, i’ll try this.

1 Like

I’d love rounddown and roundup formulae within WeWeb, too. I need to round the results of a complex formula.

Using Math.ceil works just fine in the formula view - and doesn’t particularly add complexity or unreadability to the result. All weweb formulas are wrappers for javascript functions, and they do their jobs best when they are focused on weweb-specific concerns and let the easy parts of JS do their job.

2 Likes

Nice, thanks! I didn’t know they could be combined like that.

Would I need to write a custom JS formula to round up to the nearest 10 or 100 instead of the nearest integer?

I would just do (for rounding to the nearest 10)

Math.round([myvalue]/10)*10

In the above, 993 would become 990

1 Like

Thanks, Ray - much appreciated!

I saw your business through your profile, too - awesome idea. I can see that being helpful to many.