Dynamo: Forcing Exactly One-Half to Round Up

In the same Dynamo graph on which my previous post was based, I had a need to round a real number to the nearest whole number, and I wanted a decimal of exactly .5 to round up. The Math.Round node met all my rounding needs except for when the decimal value is exactly 0.5; that node “rounds to even,” which means that both 1.5 and 2.5 will round to 2, since 2 is even. Statistically, when dealing with a large amount of data, always rounding exactly 0.5 to even (or rounding always to odd) makes sense, as always rounding up would tend to skew any mathematical analysis of the data to a higher value. In this case, the number was being used only as a label, and I decided that it should always round up.

I put together the following nodes to achieve the desired results. Numbers in the explanation below refer to the numbers in the image. As always, you can click on the image to see the full-size version.

  1. This code block provides the source number to be processed.
  2. The nodes in Area 2…

Read more