• Create Account

### #ActualBacterius

Posted 18 March 2013 - 11:00 PM

#define ONE     +1
#define TWENTY  +20
#define HUNDRED +100

// Here's a little example
#include <iostream>

int main()
{
int x = ONE;
std::cout << x << std::endl;

x = ONE HUNDRED;
std::cout << x << std::endl;

x = ONE HUNDRED TWENTY;
std::cout << x << std::endl;

x = ONE HUNDRED TWENTY ONE;
std::cout << x << std::endl;
}


Or even worse:


#define ONE     +0x001
#define TWENTY  +0x020
#define HUNDRED +0x100


TWO HUNDRED == 102


But don't worry - we can fix it! We just need to be "clever"...

#define AND +0
#define ONE +1
#define TWO +2
#define TWENTY +20
#define HUNDRED *100

// Here's a little example
#include <iostream>

int main()
{
int x = TWO HUNDRED AND TWENTY ONE;
std::cout << x << std::endl;
// prints 221
}

This way you even get to write grammatically correct numbers.

### #1Bacterius

Posted 18 March 2013 - 10:56 PM

#define ONE     +1
#define TWENTY  +20
#define HUNDRED +100

// Here's a little example
#include <iostream>

int main()
{
int x = ONE;
std::cout << x << std::endl;

x = ONE HUNDRED;
std::cout << x << std::endl;

x = ONE HUNDRED TWENTY;
std::cout << x << std::endl;

x = ONE HUNDRED TWENTY ONE;
std::cout << x << std::endl;
}


Or even worse:


#define ONE     +0x001
#define TWENTY  +0x020
#define HUNDRED +0x100


TWO HUNDRED == 102


But don't worry - we can fix it! We just need to be "clever"...

#define ONE +1
#define TWO +2
#define TWENTY +20
#define HUNDRED *100

#define TIMES *
#define PLUS +

#define AND +0

// Here's a little example
#include <iostream>

int main()
{
int x = TWO HUNDRED AND TWENTY ONE;
std::cout << x << std::endl;
// prints 221
}

This way you even get to write grammatically correct numbers.

PARTNERS