Skip to content

Commit 728fd63

Browse files
committed
Update description and documentation
1 parent b625213 commit 728fd63

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Modelica/Blocks/Math.mo

+2-2
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,7 @@ Otherwise the input angle <code>u</code> is wrapped to the <a href=\"https://en.
19311931
</html>"));
19321932
end WrapAngle;
19331933

1934-
block RealToInteger "Convert Real to Integer signal"
1934+
block RealToInteger "Convert Real to Integer signal (by rounding away from zero)"
19351935
extends Modelica.Blocks.Icons.IntegerBlock;
19361936
public
19371937
Interfaces.RealInput u "Connector of Real input signal" annotation (
@@ -1959,7 +1959,7 @@ Otherwise the input angle <code>u</code> is wrapped to the <a href=\"https://en.
19591959
30.0,-10.0},{30.0,-20.0},{50.0,0.0}})}), Documentation(info="<html>
19601960
<p>
19611961
This block computes the output <strong>y</strong>
1962-
as <em>nearest integer value</em> of the input <strong>u</strong>:
1962+
as <em>nearest integer value</em> of the input <strong>u</strong> (by rounding away from zero):
19631963
</p>
19641964
<blockquote><pre>
19651965
y = <strong>integer</strong>( <strong>floor</strong>( u + 0.5 ) ) for u &gt; 0;

Modelica/Math/nearestInteger.mo

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
within Modelica.Math;
2-
function nearestInteger "Convert real number to nearest integer value"
2+
function nearestInteger "Convert real number to nearest integer value (by rounding away from zero)"
33
extends Modelica.Icons.Function;
44

55
input Real r "Real number to convert to integer";
6-
output Integer i "Integer value, which is closest to the given real number";
6+
output Integer i "Integer value, which is nearest to the given real number (rounded away from zero)";
77

88
algorithm
99
i :=if (r > 0) then integer(floor(r + 0.5)) else integer(ceil(r - 0.5));
@@ -17,12 +17,11 @@ Math.<strong>nearestInteger</strong>(r);
1717
1818
<h4>Description</h4>
1919
<p>
20-
The input value \"r\" of type Real is converted to the closest Integer value \"i\",
21-
using the <em>round half away from zero</em> rule with the equation:
20+
The input value <code>r</code> of type Real is converted to the nearest integer value <code>i</code> (by rounding away from zero):
2221
</p>
2322
<blockquote><pre>
2423
i = <strong>integer</strong>( <strong>floor</strong>( r + 0.5 ) ) for r &gt; 0;
25-
i = <strong>integer</strong>( <strong>ceil</strong>( r - 0.5 ) ) for r &lt; 0;
24+
i = <strong>integer</strong>( <strong>ceil </strong>( r - 0.5 ) ) for r &lt; 0;
2625
</pre></blockquote>
2726
2827
<h4>Example</h4>

0 commit comments

Comments
 (0)