Rev 15712 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 15712 | Rev 15713 | ||
---|---|---|---|
Line 86... | Line 86... | ||
86 | */ |
86 | */ |
87 | #include <stdio.h> |
87 | #include <stdio.h> |
88 | #include <math.h> |
88 | #include <math.h> |
89 | #include <string.h> |
89 | #include <string.h> |
90 | #include <stdlib.h> |
90 | #include <stdlib.h> |
- | 91 | #ifdef KATEX_INSTALLED |
|
- | 92 | /* generate timebased id */ |
|
- | 93 | #include <sys/time.h> |
|
- | 94 | #endif |
|
91 | /*#define MICRO "µ"*/ |
95 | /*#define MICRO "µ"*/ |
92 | #define MICRO "\xB5" |
96 | #define MICRO "\xB5" |
93 | #define MAX_CONV 256 |
97 | #define MAX_CONV 256 |
94 | #define MAX_STRING 32 |
98 | #define MAX_STRING 32 |
95 | #define PREFIX_START -24 |
99 | #define PREFIX_START -24 |
96 | #define PREFIX_END 24 |
100 | #define PREFIX_END 24 |
- | 101 | ||
97 | 102 | ||
98 | char *str_replace ( const char *word, const char *sub_word, const char *rep_word ){ |
103 | char *str_replace ( const char *word, const char *sub_word, const char *rep_word ){ |
99 | if(strlen(word) > MAX_STRING){return NULL;} |
104 | if(strlen(word) > MAX_STRING){return NULL;} |
100 | char *part_word = NULL; |
105 | char *part_word = NULL; |
101 | char *new_word = NULL; |
106 | char *new_word = NULL; |
Line 122... | Line 127... | ||
122 | } |
127 | } |
123 | return new_word; |
128 | return new_word; |
124 | } |
129 | } |
125 | 130 | ||
126 | char *printscience(double value, int sig, int format , int cnt ,int size){ |
131 | char *printscience(double value, int sig, int format , int cnt ,int size){ |
- | 132 | #ifdef KATEX_INSTALLED |
|
- | 133 | /* generate timebased id */ |
|
- | 134 | struct timeval tv;struct timezone tz;gettimeofday(&tv, &tz); |
|
- | 135 | unsigned int id = (unsigned int) tv.tv_usec; |
|
- | 136 | #endif |
|
127 | static char *min[] = {"","m",MICRO,"n","p","f","a","z","y"}; |
137 | static char *min[] = {"","m",MICRO,"n","p","f","a","z","y"}; |
128 | static char *plus[] = {"","k", "M", "G", "T", "P", "E", "Z", "Y" }; |
138 | static char *plus[] = {"","k", "M", "G", "T", "P", "E", "Z", "Y" }; |
129 | static char *min_word[] = {"","milli","micro","nano","pico","femto","atto","zepto","yocto"}; |
139 | static char *min_word[] = {"","milli","micro","nano","pico","femto","atto","zepto","yocto"}; |
130 | static char *plus_word[] = {"","kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta" }; |
140 | static char *plus_word[] = {"","kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta" }; |
131 | char *sign = NULL;char *prefix = NULL;float pm;double factor; |
141 | char *sign = NULL;char *prefix = NULL;float pm;double factor; |
Line 212... | Line 222... | ||
212 | { |
222 | { |
213 | fprintf(stdout, "%s%.*f×10<sup>%d</sup> %s", sign, sig, value, exp, prefix); |
223 | fprintf(stdout, "%s%.*f×10<sup>%d</sup> %s", sign, sig, value, exp, prefix); |
214 | } |
224 | } |
215 | break; |
225 | break; |
216 | #ifdef KATEX_INSTALLED |
226 | #ifdef KATEX_INSTALLED |
217 | case 4: fprintf(stdout, "<span onclick='javascript:wims_mathml_zoom(this.id);' |
227 | case 4: fprintf(stdout, "<span onclick='javascript:wims_mathml_zoom(this.id);' id='wims_katex%d' class='wims_katex' use_display='false'>%s%.*f \\times 10^{%d}</span>",id, sign, sig, value, exponent10);break; |
218 | #else |
228 | #else |
219 | case 4: fprintf(stdout, "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"inline\"><mstyle id=\"wims_mathml\" mathsize=\"110%%\"><mn>%s%.*f</mn><mo>×</mo><msup><mn>10</mn><mn>%d</mn></msup></mstyle></math>", sign, sig, value, exponent10);break; |
229 | case 4: fprintf(stdout, "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"inline\"><mstyle id=\"wims_mathml\" mathsize=\"110%%\"><mn>%s%.*f</mn><mo>×</mo><msup><mn>10</mn><mn>%d</mn></msup></mstyle></math>", sign, sig, value, exponent10);break; |
220 | #endif |
230 | #endif |
221 | case 5: break; |
231 | case 5: break; |
222 | case 6: fprintf(stdout, "%s%.*f",sign,sig,value);break; |
232 | case 6: fprintf(stdout, "%s%.*f",sign,sig,value);break; |