Created
February 24, 2012 22:04
-
-
Save michael-galpin/1904083 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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