Browse Source

Fix macros for overloaded comparisons

Scott Lahteine 5 years ago
parent
commit
1803c27afb
1 changed files with 8 additions and 8 deletions
  1. 8
    8
      Marlin/src/core/macros.h

+ 8
- 8
Marlin/src/core/macros.h View File

103
 
103
 
104
   // C++11 solution that is standards compliant.
104
   // C++11 solution that is standards compliant.
105
   template <class V, class N> static inline constexpr void NOLESS(V& v, const N n) {
105
   template <class V, class N> static inline constexpr void NOLESS(V& v, const N n) {
106
-    if (v < n) v = n;
106
+    if (n > v) v = n;
107
   }
107
   }
108
   template <class V, class N> static inline constexpr void NOMORE(V& v, const N n) {
108
   template <class V, class N> static inline constexpr void NOMORE(V& v, const N n) {
109
-    if (v > n) v = n;
109
+    if (n < v) v = n;
110
   }
110
   }
111
   template <class V, class N1, class N2> static inline constexpr void LIMIT(V& v, const N1 n1, const N2 n2) {
111
   template <class V, class N1, class N2> static inline constexpr void LIMIT(V& v, const N1 n1, const N2 n2) {
112
-    if (v < n1) v = n1;
113
-    else if (v > n2) v = n2;
112
+    if (n1 > v) v = n1;
113
+    else if (n2 < v) v = n2;
114
   }
114
   }
115
 
115
 
116
 #else
116
 #else
120
   #define NOLESS(v, n) \
120
   #define NOLESS(v, n) \
121
     do{ \
121
     do{ \
122
       __typeof__(n) _n = (n); \
122
       __typeof__(n) _n = (n); \
123
-      if (v < _n) v = _n; \
123
+      if (_n > v) v = _n; \
124
     }while(0)
124
     }while(0)
125
 
125
 
126
   #define NOMORE(v, n) \
126
   #define NOMORE(v, n) \
127
     do{ \
127
     do{ \
128
       __typeof__(n) _n = (n); \
128
       __typeof__(n) _n = (n); \
129
-      if (v > _n) v = _n; \
129
+      if (_n < v) v = _n; \
130
     }while(0)
130
     }while(0)
131
 
131
 
132
   #define LIMIT(v, n1, n2) \
132
   #define LIMIT(v, n1, n2) \
133
     do{ \
133
     do{ \
134
       __typeof__(n1) _n1 = (n1); \
134
       __typeof__(n1) _n1 = (n1); \
135
       __typeof__(n2) _n2 = (n2); \
135
       __typeof__(n2) _n2 = (n2); \
136
-      if (v < _n1) v = _n1; \
137
-      else if (v > _n2) v = _n2; \
136
+      if (_n1 > v) v = _n1; \
137
+      else if (_n2 < v) v = _n2; \
138
     }while(0)
138
     }while(0)
139
 
139
 
140
 #endif
140
 #endif

Loading…
Cancel
Save