You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/lang.rst
+12-2Lines changed: 12 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -153,8 +153,8 @@ Shapes from ranges
153
153
154
154
Casting a shape from a :class:`range` ``r`` produces a shape that:
155
155
156
-
* has a width large enough to represent both ``min(r)`` and ``max(r)``, and
157
-
* is signed if either ``min(r)`` or ``max(r)`` are negative, unsigned otherwise.
156
+
* has a width large enough to represent both ``min(r)`` and ``max(r)``, but not larger, and
157
+
* is signed if ``r`` contains any negative values, unsigned otherwise.
158
158
159
159
Specifying a shape with a range is convenient for counters, indexes, and all other values whose width is derived from a set of numbers they must be able to fit:
160
160
@@ -184,6 +184,16 @@ Specifying a shape with a range is convenient for counters, indexes, and all oth
184
184
185
185
Amaranth detects uses of :class:`Const` and :class:`Signal` that invoke such an off-by-one error, and emits a diagnostic message.
186
186
187
+
.. note::
188
+
189
+
An empty range always casts to an ``unsigned(0)``, even if both of its bounds are negative.
190
+
This happens because, being empty, it does not contain any negative values.
0 commit comments