@@ -93,12 +93,14 @@ public sealed class Counter private constructor() {
93
93
* - [incrementBy] is less than or equal to 0
94
94
* - [incrementBy] is greater than [MAX_INCREMENT]
95
95
* - [incrementBy] is not a factor of 8
96
+ * - [incrementBy] does not go into [Int.MIN_VALUE] (i.e. when `Int.MIN_VALUE % incrementBy != 0`)
96
97
* - [lo] is not a factor of [incrementBy]
97
98
* */
98
99
public constructor (lo: Int , hi: Int , incrementBy: Int ): super () {
99
100
require(incrementBy > 0 ) { " incrementBy[$incrementBy ] must be greater than 0" }
100
101
require(incrementBy <= MAX_INCREMENT ) { " incrementBy[$incrementBy ] must be less than or equal to $MAX_INCREMENT " }
101
102
require(incrementBy % 8 == 0 ) { " incrementBy[$incrementBy ] must be a factor of 8" }
103
+ require(Int .MIN_VALUE % incrementBy == 0 ) { " Long.MIN_VALUE % incrementBy[$incrementBy ] != 0" }
102
104
require(lo % incrementBy == 0 ) { " lo must be a factor of incrementBy[$incrementBy ]" }
103
105
104
106
this .incrementBy = incrementBy
@@ -210,12 +212,14 @@ public sealed class Counter private constructor() {
210
212
* - [incrementBy] is less than or equal to 0
211
213
* - [incrementBy] is greater than [MAX_INCREMENT]
212
214
* - [incrementBy] is not a factor of 8
215
+ * - [incrementBy] does not go into [Long.MIN_VALUE] (i.e. when `Long.MIN_VALUE % incrementBy != 0`)
213
216
* - [lo] is not a factor of [incrementBy]
214
217
* */
215
218
public constructor (lo: Long , hi: Long , incrementBy: Long ): super () {
216
219
require(incrementBy > 0L ) { " incrementBy[$incrementBy ] must be greater than 0" }
217
220
require(incrementBy <= MAX_INCREMENT ) { " incrementBy[$incrementBy ] must be less than or equal to $MAX_INCREMENT " }
218
221
require(incrementBy % 8 == 0L ) { " incrementBy[$incrementBy ] must be a factor of 8" }
222
+ require(Long .MIN_VALUE % incrementBy == 0L ) { " Long.MIN_VALUE % incrementBy[$incrementBy ] != 0" }
219
223
require(lo % incrementBy == 0L ) { " lo must be a factor of incrementBy[$incrementBy ]" }
220
224
221
225
this .incrementBy = incrementBy
0 commit comments