Rounding Numbers up to the Nearest .XXX5
  • 21 Sep 2023
  • 1 Minute to read
  • Dark
    Light

Rounding Numbers up to the Nearest .XXX5

  • Dark
    Light

Article summary

Example Lab Article
While Example Lab projects are resources for public use, articles and assets are not actively maintained. Screenshots and features are from the specified version below. These references may become dated as new versions are released.

Overview

Example Lab Details

Version6.9.2
Root FolderExample Lab - Rounding Numbers
Modules None
DependenciesNone

This Example Lab project demonstrates how to round a number up to the nearest X.XXX5 place. This project does not function to round numbers conventionally.


Explanation

This Example Lab project rounds numbers up to the nearest X.XXX5. For example, 1.0006 would round to 1.0010. It only rounds numbers up, not down, to either the nearest .0005 if the 4th decimal place is under 5 but not zero, or it will round up to ten if the fourth decimal place is above five. 

This project works by showing a Form that requests the user to input a number with four decimal places (the Form will round the number to four decimal places if more than four are inserted). The number is then sent to a Sub-Flow titled "Round Sub Flow", where the logic to round the number is carried out. The Sub-Flow determines what number is in the 4th decimal place, evaluating if the number needs to be increased and, if so, by how much. The Sub-Flow contains a truth table within it to process this evaluation.

If the input number is 6.0037, the Flow would isolate the 7 and run it against the truth table. Since 7 will need to be rounded up, the truth table would output how much to add to the number in order for it to reach 10. The Flow then uses the Evaluate Dynamic Expression step to evaluate ((Number*10000)+Result)/10000, returning the number back to its original form so that it can be passed out of the Sub-Flow and shown to the user in the main Flow.

Reference Articles



Project Download

The examples attached were developed to be instructional and were not developed as officially supported components. For more information or to engage our service team to develop fully supported, production-quality solutions, please contact services@decisions.com. Import the project below to a Decisions environment on version 6.9.2 or later using our Importing/Exporting article.




Was this article helpful?