commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cahangirova Gunel <gune...@gmail.com>
Subject [math] Negative max in class Incrementor
Date Wed, 26 Aug 2015 16:33:29 GMT
Dear all,

Recently I have reported a bug (in my opinion) MATH-1259 in class Incrementor from the org.apache.commons.math4.util
package, as it is possible to pass a negative number for the max variable. Given that the
count variable is initialised to 0 by default, it means that canIncrement() method will always
return false. 
I wondered whether it is an acceptable behaviour, given that documentation says that Incrementor
is a utility that increments a counter until a maximum is reached. And in the case of a negative
max this maximum is not reachable at all.

The reply by Gilles was that initially the concept of a class was of a "counter" rather than
an “incrementor”, so one suggested change might be to make the class an incrementor by
specifying initial and final values, rather than just count number, and the other suggested
change is to just forbid negative counts by throwing an exception.

The question of which change to apply needs a further discussion.

Best regards,
Gunel Jahangirova.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message