summaryrefslogtreecommitdiff
path: root/src/value.h
diff options
context:
space:
mode:
authorVicnet <vo.publique@gmail.com>2013-10-07 14:02:43 (GMT)
committerVicnet <vo.publique@gmail.com>2013-10-07 14:04:43 (GMT)
commiteb27a0277f1eb08e947f5d4e4036f5fe13dfe086 (patch)
treea57f9de205e4b9a2f8d7849690c68ac37940b637 /src/value.h
parent9bc73ac106a78398b744c2cd6c997055d8d2de9d (diff)
factorize Value::RangeType calculation and correct error
Diffstat (limited to 'src/value.h')
-rw-r--r--src/value.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/value.h b/src/value.h
index 4d8346f..388b721 100644
--- a/src/value.h
+++ b/src/value.h
@@ -4,6 +4,7 @@
#include <vector>
#include <string>
#include <algorithm>
+#include <limits>
// Workaround for https://bugreports.qt-project.org/browse/QTBUG-22829
#ifndef Q_MOC_RUN
@@ -42,10 +43,17 @@ public:
/// inverse begin/end if begin is upper than end
void normalize() {
- if (end < begin) {
+ if ((step>0) && (end < begin)) {
std::swap(begin,end);
}
}
+ /// return number of steps, max int value if step is null
+ int nbsteps() const {
+ if (step<=0) {
+ return std::numeric_limits<int>::max();
+ }
+ return (int)((begin-end)/step);
+ }
double begin;
double step;
contact: Jan Huwald // Impressum