Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Round up to nearest n. Simpler calculation?

Featured Replies

Hi all,

I have a need for a calculation that rounds up positive numbers to the nearest n, with n being equal to whatever value the user enters. I wrote a calc for it that seems to do precisely that but I just have this nagging feeling that it's "taking the long way around the barn". Can anyone simplify this?

Case (

roundValue * Int( Round( inputNumber;0 ) / roundValue ) > inputNumber ;

roundValue * Int( Round( inputNumber;0 ) / roundValue );

roundValue * Int( Round( inputNumber;0 ) / roundValue ) + roundValue)

See the attachment for more info.

Any help would be appreciated...thanks in advance!

RoundTest.zip

To round up add 1/2 (0.5) to the number before rounding->

e.g. Round(123.456 ; 0) returns 123

Round(123.456 + 0.5; 0) returns 124

Mathematically, the standard is to round up for values >= x.5. So adding .5 forces any x.y to round up to x + 1.

Try:

Ceiling ( inputNumber / roundValue ) * roundValue

  • Author

I knew that the Ceiling() function had to be part of the solution, but I just couldn't come up with the correct formula. Thanks a bunch, Comment! B)

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.