00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <stdio.h>
00025 #include <string.h>
00026 #include "doc_Text.hh"
00027 #include "compatibility.hh"
00028 #include <string>
00029 #include <vector>
00030 #include <iostream>
00031 #include <sstream>
00032 #include <assert.h>
00033
00034 #include "floats.hh"
00035
00036 extern bool gInternDoubleSwitch;
00037 string scientific2tenpow (double n);
00038
00039
00040
00041 #if 0
00042
00048 static void zdel(char* c)
00049 {
00050 int l = strlen(c) - 1;
00051 bool f = (c[l] == 'f');
00052
00053 if (f) c[l--] = 0;
00054 while ( l>1 && c[l-1] != '.' && c[l] == '0') c[l--] = 0;
00055 if (f) c[++l] = 'f';
00056 }
00057 #endif
00058
00059 string docT (char* c) { return string(c); }
00060 string docT (int n) { char c[64]; snprintf(c, 63, "%d",n); return string(c); }
00061 string docT (long n) { char c[64]; snprintf(c, 63, "%ld",n); return string(c); }
00062
00063 #if 0
00064 string docT (float n)
00065 {
00066 char c[64];
00067 if (n < 0.1 && n > -0.1 && n != 0.0) {
00068
00069 string s = scientific2tenpow(n);
00070 snprintf(c, 63, "%s", s.c_str());
00071 } else {
00072 snprintf(c, 63, "%f", n);
00073 zdel(c);
00074 }
00075 return string(c);
00076 }
00077 #endif
00078
00084 string docT (double n)
00085 {
00086
00087
00088
00091
00092
00093
00094
00095
00096
00097 return scientific2tenpow(n);
00098 }
00099
00100 string scientific2tenpow (double n)
00101 {
00102 char tmp[64];
00103 string entree = " * 10^{";
00104 char sortie = '}';
00105 string s;
00106 string::size_type ps;
00107
00108 snprintf(tmp, 63, "%g", n);
00109
00110
00111 s = tmp;
00112 ps = s.find('e');
00113
00114 if (ps != string::npos) {
00115 s.replace(ps, 1, "");
00116 s.insert(ps, entree);
00117 s += sortie;
00118 }
00119 else {
00120
00121 }
00122
00123 return s;
00124 }