blockRound

Round real number to given digits

Information

Block that outputs the input after rounding it to n digits.

For example,

  • set n = 0 to round to the nearest integer,
  • set n = 1 to round to the next decimal point, and
  • set n = -1 to round to the next multiple of ten.

Hence, the block outputs

    y = floor(u*(10^n) + 0.5)/(10^n)  for  u > 0,
    y = ceil(u*(10^n) - 0.5)/(10^n)   for  u < 0.

Parameters

TypeNameDefaultDescription
IntegernNumber of digits to be round to

Connectors

TypeNameDefaultDescription
Buildings.Controls.OBC.CDL.Interfaces.RealInputuInput to be rounded
Buildings.Controls.OBC.CDL.Interfaces.RealOutputyOutput with rounded input

Revisions

  • March 2, 2020, by Michael Wetter:
    Changed icon to display dynamically the output value.
  • September 14, 2017, by Jianjun Hu:
    First implementation, based on the implementation of the Modelica Standard Library.