From 2d7d2f09189d57b47863d2ce89b6a450f4402681 Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Fri, 16 Jan 2026 19:05:23 +0100 Subject: Finish all printing including latex and niceties for printing 0 and 1 and such. --- double.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'double.c') diff --git a/double.c b/double.c index b84b49a..eba6127 100644 --- a/double.c +++ b/double.c @@ -33,12 +33,24 @@ double valuetype_to_double(double d){ return d; } double inv_exptype_to_double(double d){ return 1.0/d; } -int to_string(char* s, double d){ +int valuetype_to_string(char* s, double d){ sprintf(s,"%f",d); return 0; } +int valuetype_to_latex(char* s, double d){ + if( d == 0.0) sprintf(s,"$0$"); + else if( d == 1.0) sprintf(s,"$1$"); + else sprintf(s,"$%4.3f$",d); + return 0; +} + int root_to_string(char* s, double d, double p){ - to_string(s,pow(d,1/p)); + valuetype_to_string(s,pow(d,1.0/p)); + return 0; +} + +int root_to_latex(char* s, double d, double p){ + valuetype_to_latex(s,pow(d,1.0/p)); return 0; } -- cgit v1.2.3