blockRound
Round real number to given digits
Information
Block 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 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
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | n | Number of digits to be round to |
Connectors
| Type | Name | Default | Description |
|---|---|---|---|
| Buildings.Controls.OBC.CDL.Interfaces.RealInput | u | Input to be rounded | |
| Buildings.Controls.OBC.CDL.Interfaces.RealOutput | y | Output 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.