diff options
Diffstat (limited to 'ratio.c')
| -rw-r--r-- | ratio.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -129,20 +129,20 @@ rational power(rational r, unsigned int p){ return s; } -double to_double(rational r){ +double valuetype_to_double(rational r){ double i; if(r.s) { i=-1.0; } else { i=1.0; } return i*((double)r.n)/((double)r.d); } int to_string(char* s, rational r){ - double f = to_double(r); + double f = valuetype_to_double(r); sprintf(s,"%llu / %llu = %f… +/- %6.1e",r.n,r.d,f,f*DBL_EPSILON); return 0; } int root_to_string(char* s, rational r, unsigned int p){ - double f = pow(to_double(r),1.0/p); + double f = pow(valuetype_to_double(r),1.0/p); sprintf(s,"(%llu / %llu)^1/%i = %f… +/- %6.1e",r.n,r.d,p,f,2*DBL_EPSILON*f); return 0; } |
