Skip to content

Commit 337d3a6

Browse files
committed
doc
1 parent 564c104 commit 337d3a6

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

src/gfloat/types.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,31 @@ class RoundMode(Enum):
88
"""
99
Enum for IEEE-754 rounding modes.
1010
11-
Result r is obtained from input v depending on rounding mode as follows
11+
Result :math:`r` is obtained from input :math:`v` depending on rounding mode as follows
12+
13+
Notes on stochastic rounding:
14+
15+
StochasticFast implements a stochastic rounding scheme that is unbiased in
16+
infinite precision, but biased when the quantity to be rounded is computed to
17+
a finite precision.
18+
19+
StochasticFastest implements a stochastic rounding scheme that is biased
20+
(the rounded value is on average farther from zero than the true value).
21+
22+
With a lot of SRbits (say 8 or more), these biases are negligible, and there
23+
may be some efficiency advantage in using StochasticFast or StochasticFastest.
24+
1225
"""
1326

14-
TowardZero = 1 #: :math:`\max \{ r ~ s.t. ~ |r| \le |v| \}`
15-
TowardNegative = 2 #: :math:`\max \{ r ~ s.t. ~ r \le v \}`
16-
TowardPositive = 3 #: :math:`\min \{ r ~ s.t. ~ r \ge v \}`
27+
TowardZero = 1 #: Return the largest :math:`r` such that :math:`|r| \le |v|`
28+
TowardNegative = 2 #: Return the largest :math:`r` such that :math:`r \le v`
29+
TowardPositive = 3 #: Return the smallest :math:`r` such that :math:`r \ge v`
1730
TiesToEven = 4 #: Round to nearest, ties to even
1831
TiesToAway = 5 #: Round to nearest, ties away from zero
19-
Stochastic = 6 #: Stochastic rounding
20-
StochasticFast = 7 #: Stochastic rounding - faster, but biased, see [Note 1].
21-
StochasticFastest = 8 #: Stochastic rounding - incorrect, see [Note 1].
22-
StochasticOdd = 9 #: Stochastic rounding, RTNO before comparison
23-
24-
25-
# [Note 1]:
26-
# StochasticFast implements a stochastic rounding scheme that is unbiased in
27-
# infinite precision, but biased when the quantity to be rounded is computed to
28-
# a finite precision.
29-
#
30-
# StochasticFastest implements a stochastic rounding scheme that is biased
31-
# (the rounded value is on average farther from zero than the true value).
32-
#
33-
# With a lot of SRbits (say 8 or more), these biases are negligible, and there
34-
# may be some efficiency advantage in using StochasticFast or StochasticFastest.
32+
Stochastic = 6 #: Stochastic rounding, RTNE before comparison
33+
StochasticOdd = 7 #: Stochastic rounding, RTNO before comparison
34+
StochasticFast = 8 #: Stochastic rounding - faster, but biased
35+
StochasticFastest = 9 #: Stochastic rounding - even faster, but more biased
3536

3637

3738
class FloatClass(Enum):

0 commit comments

Comments
 (0)