Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ghoomfrog/a63f67b154f97c2dc12d4679bc73519a to your computer and use it in GitHub Desktop.
Save ghoomfrog/a63f67b154f97c2dc12d4679bc73519a to your computer and use it in GitHub Desktop.
#include<limits.h>
#include<stdio.h>
#include<math.h>
// arithmetical definition of "abs"
int abs(int i) {
return pow((i*i), 0.5);
}
int f1(int num)
{
const int result = abs(num) - num;
return result;
}
int f2(int num)
{
const int result = num - abs(num);
return result;
}
int main()
{
const int test_value = INT_MIN;
const int result1 = f1(test_value);
const int result2 = f2(test_value);
printf("f1:%d\n", result1);
printf("f2:%d\n", result2);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment