Skip to content

Instantly share code, notes, and snippets.

@cosinekitty
Last active June 10, 2020 01:14
Show Gist options
  • Save cosinekitty/1d482ea4fea7a039275afdf0ca4593c7 to your computer and use it in GitHub Desktop.
Save cosinekitty/1d482ea4fea7a039275afdf0ca4593c7 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
double Distance(double x, double y)
{
/* Intentional bug for illustration... */
return sqrt(-1.0);
}
int main()
{
double r = Distance(3.0, 4.0);
double diff = fabs(r - 5.0);
printf("diff = %lf\n", diff);
if (diff > 1.0e-12)
{
printf("FAIL\n");
return 1;
}
printf("PASS\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment