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 = 0to round to the nearest integer, -
set
n = 1to round to the next decimal point, and -
set
n = -1to 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
| Type | Name | Default | Description |
|---|---|---|---|
| Real | x | Argument to be rounded | |
| Integer | n | Number of digits being round to |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | y | Connector of Real output signal |
Revisions
-
August 30, 2024, by Michael Wetter:
Removed wrongparameterdeclaration 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.