Skip to content

Instantly share code, notes, and snippets.

@dbremner
Created March 18, 2019 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dbremner/2226a0cfae5630e574f30331ae4d997c to your computer and use it in GitHub Desktop.
Save dbremner/2226a0cfae5630e574f30331ae4d997c to your computer and use it in GitHub Desktop.
#include<limits.h>
#include<stdlib.h>
#include<stdio.h>
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