Skip to content

Commit 4517146

Browse files
committed
Explain plus-minus zero situation
1 parent 53efb5d commit 4517146

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Sources/BitWriter.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ extension BitWriter {
7575

7676
The default value of `representation` is `SignedNumberRepresentation.twoComplementNegatives`.
7777

78+
For the representations where zero can be represented in two ways (namely, `.signMagnitude` and
79+
`.oneComplementNegatives`), zero is encoded as +0 (i.e. all bits are set to zero).
80+
7881
- Precondition: The `signedNumber` must be representable within `bitsCount` bits using the `representation`, i.e.
7982
it must be in the `representation.minRepresentableNumber...representation.maxRepresentableNumber` range.
8083
- Precondition: For the `SignedNumberRepresentation.biased` representation, the `bias` must be non-negative.

0 commit comments

Comments
 (0)