Skip to content

Instantly share code, notes, and snippets.

@michael-galpin
Created February 24, 2012 22:04
Show Gist options
  • Save michael-galpin/1904083 to your computer and use it in GitHub Desktop.
Save michael-galpin/1904083 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <float.h>
float calcMinFloat();
int main()
{
float f;
f = FLT_MIN;
printf("Min float %e\n", f);
f = calcMinFloat();
printf("Min float calculated %e\n", f);
return 0;
}
float calcMinFloat()
{
float a,b,c;
a = 1.0;
b = 0.0;
while (a - b != 0.0){
c = 0.5*(a - b);
if (c < 0.0){
b = b - c;
} else if (c == 0.0) {
b = a;
} else {
a = a -c;
}
}
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment