#include <stdio.h>

#include <math.h>

int isGreater(int a, int b)

{

return (!((a-b) >> (sizeof(a) * 8 >> 1)));

}

#define IS_GREATER(a,b) (!((a-b) >> (sizeof(a) * 8 >> 1)))

#define IS_LOWER(a,b) (((a-b) >> (sizeof(a) * 8 >> 1)))

#define MAXOFTWO(a,b) (a - ((!(IS_GREATER(a,b))*(a-b))))

#define _MAXOFTWO(a,b) ((a+b+(abs(a-b)))/2)

#define __MAXOFTWO(a,b) (a ^ ((a^b) & -(a < b)))

//#define GET_MAXOFTWO(a,b) ((sqrt(a*a+b*b-2*a*b) + a + b)/2)

int main()

{

printf("Hello, World!\n");

int a = 123, b = 90;

printf("%d\n",isGreater(a,b));

printf("%d\n",IS_GREATER(a,b));

printf("%d\n",MAXOFTWO(a,b));

printf("%d\n",_MAXOFTWO(a,b));

printf("%d\n",__MAXOFTWO(a,b));

//printf("%d\n",GET_MAXOFTWO(a,b));

return 0;

}

OutPut:

Hello,World!

1

1

123

123

123

#include <math.h>

int isGreater(int a, int b)

{

return (!((a-b) >> (sizeof(a) * 8 >> 1)));

}

#define IS_GREATER(a,b) (!((a-b) >> (sizeof(a) * 8 >> 1)))

#define IS_LOWER(a,b) (((a-b) >> (sizeof(a) * 8 >> 1)))

#define MAXOFTWO(a,b) (a - ((!(IS_GREATER(a,b))*(a-b))))

#define _MAXOFTWO(a,b) ((a+b+(abs(a-b)))/2)

#define __MAXOFTWO(a,b) (a ^ ((a^b) & -(a < b)))

//#define GET_MAXOFTWO(a,b) ((sqrt(a*a+b*b-2*a*b) + a + b)/2)

int main()

{

printf("Hello, World!\n");

int a = 123, b = 90;

printf("%d\n",isGreater(a,b));

printf("%d\n",IS_GREATER(a,b));

printf("%d\n",MAXOFTWO(a,b));

printf("%d\n",_MAXOFTWO(a,b));

printf("%d\n",__MAXOFTWO(a,b));

//printf("%d\n",GET_MAXOFTWO(a,b));

return 0;

}

OutPut:

Hello,World!

1

1

123

123

123

## 0 comments :

## Post a Comment