summaryrefslogtreecommitdiff
path: root/double.c
diff options
context:
space:
mode:
Diffstat (limited to 'double.c')
-rw-r--r--double.c16
1 files changed, 14 insertions, 2 deletions
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;
}