dumb question. Just started using C++ macros, but can't understand what's wrong here.
#include <iostream>
using namespace std;
#define ABS(a) ((a < 0) ? (-a) : (a))
int main() {
uint16_t a = 0xf0, b = 0xf8;
cout << a << " " << b << " " << a - b <<" " << ABS(a - b) << endl;
int c = a, d = b;
cout << c << " " << d << " " << c - d << " " << ABS(c - d) << endl;
}
The output is following:
240 248 -8 -488
240 248 -8 -488
Tried with signed and unsigned, but the macro result is always the same.