From 944f90c47ffcde862dfe5f258de0b1ebf229c20e Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Sun, 28 Dec 2025 11:20:32 +0000 Subject: Implement double arithmetic with error bounds. --- ratio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ratio.c') diff --git a/ratio.c b/ratio.c index 8f86f93..384f944 100644 --- a/ratio.c +++ b/ratio.c @@ -2,6 +2,7 @@ #include #include #include +#include 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; } -- cgit v1.2.3