Rev 12258 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 12258 | Rev 15712 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | type (optional args): calc = 0 / html = 1 / latex = 2 / prefix = 3 / mathml = 4 |
15 | type (optional args): calc = 0 / html = 1 / latex = 2 / prefix = 3 / mathml = 4 |
16 | 16 | ||
17 | default : calc notation : 120000,3 -> 1.20*10^5 |
17 | default : calc notation : 120000,3 -> 1.20*10^5 |
18 | type = 0 : calc notation : 120000,3,0 -> 1.20*10^5 |
18 | type = 0 : calc notation : 120000,3,0 -> 1.20*10^5 |
19 | type = 1 : html notation : 120000,3,1 -> 1.20×10<sup>5</sup> |
19 | type = 1 : html notation : 120000,3,1 -> 1.20×10<sup>5</sup> |
20 | type = 2 : |
20 | type = 2 : tex notation : 120000,3,2 -> 1.20 \times 10^{5} |
21 | type = 3 : prefix-notation : 120000,3,3 -> 120.0 k |
21 | type = 3 : prefix-notation : 120000,3,3 -> 120.0 k |
22 | type = 3 : if -24 > prefix > 24 -> type = 1 (html) |
22 | type = 3 : if -24 > prefix > 24 -> type = 1 (html) |
23 | type = 4 : |
23 | type = 4 : MathML notation or KaTeX (e.g. tex notation in 'span' element with: class='wims_katex' zoom enabled) |
24 | type = 5 : prefix-notation with words (nano,mega,giga...etc) :120000,3,3 -> 120.0 kilo |
24 | type = 5 : prefix-notation with words (nano,mega,giga...etc) :120000,3,3 -> 120.0 kilo (same as 3) |
25 | 25 | ||
26 | multiple conversion: use |
26 | multiple conversion: use 'space' between arguments |
27 | scienceprint 120000,4 122900,5 120036,6,3 --> 120.0*10^3,122.90*10^3,120.036 k |
27 | scienceprint 120000,4 122900,5 120036,6,3 --> 120.0*10^3,122.90*10^3,120.036 k |
28 | 28 | ||
29 | 29 | ||
30 | ********************************************************************************* |
30 | ********************************************************************************* |
- | 31 | CHANGELOG |
|
- | 32 | 19/2/2021 |
|
- | 33 | added compile time support for KaTeX installation (in case 'type = 4': MathML --> KaTeX span element) |
|
- | 34 | ||
31 | 16/10/2013 |
35 | 16/10/2013 |
32 | corrected roundoff in case "significance=-1" changed 'factor' from 'int' to 'float'...there must be a better way to do this... |
36 | corrected roundoff in case "significance=-1" changed 'factor' from 'int' to 'float'...there must be a better way to do this... |
33 | But in numbers > 1000000000000000 there is still a problem, so take care (!) |
37 | But in numbers > 1000000000000000 there is still a problem, so take care (!) |
34 | when there are more than 15 digits in the number (this may vary depending on system / implementations, I guess) |
38 | when there are more than 15 digits in the number (this may vary depending on system / implementations, I guess) |
35 | ./scienceprint 901234567890123 ,-1,0 --> 9.01234567890123*10^14 |
39 | ./scienceprint 901234567890123 ,-1,0 --> 9.01234567890123*10^14 |
Line 207... | Line 211... | ||
207 | else |
211 | else |
208 | { |
212 | { |
209 | fprintf(stdout, "%s%.*f×10<sup>%d</sup> %s", sign, sig, value, exp, prefix); |
213 | fprintf(stdout, "%s%.*f×10<sup>%d</sup> %s", sign, sig, value, exp, prefix); |
210 | } |
214 | } |
211 | break; |
215 | break; |
- | 216 | #ifdef KATEX_INSTALLED |
|
- | 217 | case 4: fprintf(stdout, "<span onclick='javascript:wims_mathml_zoom(this.id);' id='wims_katex0' class='wims_katex' use_display='false'>%s%.*f \\times 10^{%d}</span>", sign, sig, value, exponent10);break; |
|
- | 218 | #else |
|
212 | 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; |
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; |
- | 220 | #endif |
|
213 | case 5: break; |
221 | case 5: break; |
214 | case 6: fprintf(stdout, "%s%.*f",sign,sig,value);break; |
222 | case 6: fprintf(stdout, "%s%.*f",sign,sig,value);break; |
215 | default: break; |
223 | default: break; |
216 | } |
224 | } |
217 | return NULL; |
225 | return NULL; |