functionround

Round real number to specified digits

Extends from Modelica.Icons.Function (Icon for functions).

Information

Function 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 function outputs

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

To use this function as a block, use AixLib.Controls.OBC.CDL.Reals.Round.

Inputs

TypeNameDefaultDescription
RealxArgument to be rounded
IntegernNumber of digits being round to

Outputs

TypeNameDefaultDescription
RealyConnector of Real output signal

Revisions

  • August 30, 2024, by Michael Wetter:
    Removed wrong parameter declaration on a protected variable which causes an error in Dymola 2025x beta1.
    This is for Buildings, #3978.
  • March 2, 2020, by Michael Wetter:
    First implementation.
    This is for Buildings, #2170.