summaryrefslogtreecommitdiff
path: root/ratio.c
diff options
context:
space:
mode:
Diffstat (limited to 'ratio.c')
-rw-r--r--ratio.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ratio.c b/ratio.c
index 8f86f93..384f944 100644
--- a/ratio.c
+++ b/ratio.c
@@ -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;
}