diff options
Diffstat (limited to 'ratio.c')
| -rw-r--r-- | ratio.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -2,6 +2,7 @@ #include <stdlib.h> #include <math.h> #include <limits.h> +#include <float.h> typedef unsigned long long num; @@ -35,6 +36,8 @@ rational convert_int(int i){ return r; } +unsigned int to_exptype(unsigned int i){ return i; } + num gcd(num a, num b){ num c; while (b) { @@ -120,6 +123,7 @@ double to_double(rational r){ } bool to_string(char* s,rational r){ - sprintf(s,"%llu / %llu",r.n,r.d); + double f = to_double(r); + sprintf(s,"%llu / %llu = %f +- %.24f",r.n,r.d,f,f*DBL_EPSILON); return true; } |
