@@ -237,27 +237,44 @@ way. To resolve these problems, I would like to do several changes.
237237``` swift
238238public enum SignedNumberRepresentation {
239239 case signMagnitude
240- case oneComplement
241- case twoComplement
240+ case oneComplementNegatives
241+ case twoComplementNegatives
242242 case biased (bias : Int )
243243 case radixNegativeTwo
244244}
245245```
246246
247- 2 . Add methods to bit readers and writers which will allow to read signed integers using the specified representation:
247+ Alternatively, one can name 1's and 2's complement cases as just ` oneComplement ` and ` twoComplement ` correspondingly.
248+ We believe that the current naming is better, since it emphasizes the fact that only negative numbers are encoded as the
249+ complements, and positive numbers are encoded as is.
250+
251+ 2 . Add instance methods to this new enum which will allow to query the minimum and maximum numbers that can be represented
252+ by a given representation using the specified amount of bits:
253+
254+ ``` swift
255+ public enum SignedNumberRepresentation {
256+ // ...
257+
258+ public func minRepresentableNumber (bitsCount : Int ) -> Int { ... }
259+
260+ public func maxRepresentableNumber (bitsCount : Int ) -> Int { ... }
261+ }
262+ ```
263+
264+ 3 . Add methods to bit readers and writers which will allow to read signed integers using the specified representation:
248265
249266``` swift
250267// BitWriter:
251- func write (signedNumber : Int , bitsCount : Int , representation : SignedNumberRepresentation = .twoComplement )
268+ func write (signedNumber : Int , bitsCount : Int , representation : SignedNumberRepresentation = .twoComplementNegatives )
252269
253270// BitReader:
254- func signedInt (fromBits count : Int , representation : SignedNumberRepresentation = .twoComplement ) -> Int
271+ func signedInt (fromBits count : Int , representation : SignedNumberRepresentation = .twoComplementNegatives ) -> Int
255272```
256273
257- The default value of the ` representation ` argument is ` .twoComplement ` since it the most common way to encode signed
258- integers (it is even used internally by Swift).
274+ The default value of the ` representation ` argument is ` .twoComplementNegatives ` since it the most common way to encode
275+ signed integers (it is even used internally by Swift).
259276
260- 3 . Modify the behavior of the existing functions as following:
277+ 4 . Modify the behavior of the existing functions as following:
261278
262279``` swift
263280// BitWriter:
0 commit comments