Difference between revisions of "Template:Constant"
imported>Diriector Doc |
imported>Diriector Doc (Added tau (2pi) and phi (golden ratio)) |
||
| Line 2: | Line 2: | ||
|pi = {{#switch: {{{2|value}}} | |pi = {{#switch: {{{2|value}}} | ||
|value = {{#ifexpr: {{{places|8}}} > 50 | |value = {{#ifexpr: {{{places|8}}} > 50 | ||
| − | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be | + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} |
<!-- -->|{{#ifexpr: {{{places|8}}} < 0 | <!-- -->|{{#ifexpr: {{{places|8}}} < 0 | ||
| − | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be | + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} |
<!-- -->|{{#ifeq: {{mod|{{{places|8}}}|1}} | 0 | <!-- -->|{{#ifeq: {{mod|{{{places|8}}}|1}} | 0 | ||
<!-- -->|{{#ifeq: {{{places|8}}} | 0 | <!-- -->|{{#ifeq: {{{places|8}}} | 0 | ||
| − | + | <!-- -->|3 | |
| − | + | <!-- -->|{{#switch: {{{round|no}}} | |
| − | + | <!-- -->|yes = {{Str left|3.14159265358979323846264338327950288419716939937510|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | |
|3.141592653589793238462643383279502884197169399375105|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | |3.141592653589793238462643383279502884197169399375105|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| − | + | <!-- -->|y = {{Str left|3.14159265358979323846264338327950288419716939937510|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | |
|3.141592653589793238462643383279502884197169399375105|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | |3.141592653589793238462643383279502884197169399375105|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| − | + | <!-- -->|true = {{Str left|3.14159265358979323846264338327950288419716939937510|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | |
|3.141592653589793238462643383279502884197169399375105|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | |3.141592653589793238462643383279502884197169399375105|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| − | + | <!-- -->|#default = {{Str left|3.141592653589793238462643383279502884197169399375105|{{#expr: {{{places|8}}} + 2}}}} | |
| − | + | <!-- --> }} | |
| − | + | <!-- --> }} | |
| − | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be | + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} |
<!-- --> }} | <!-- --> }} | ||
<!-- --> }} | <!-- --> }} | ||
| Line 27: | Line 27: | ||
|true = [[Pi|{{pi}}]] | |true = [[Pi|{{pi}}]] | ||
|#default = {{pi}} | |#default = {{pi}} | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
}} | }} | ||
}} | }} | ||
|e = {{#switch: {{{2|value}}} | |e = {{#switch: {{{2|value}}} | ||
| − | |value = {{#ifexpr: {{{places|8}}} > | + | |value = {{#ifexpr: {{{places|8}}} > 50 |
| − | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be | + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} |
<!-- -->|{{#ifexpr: {{{places|8}}} < 0 | <!-- -->|{{#ifexpr: {{{places|8}}} < 0 | ||
| − | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be | + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} |
<!-- -->|{{#ifexpr: {{mod|{{{places|8}}}|1}} = 0 | <!-- -->|{{#ifexpr: {{mod|{{{places|8}}}|1}} = 0 | ||
<!-- -->|{{#ifeq: {{{places|8}}} | 0 | <!-- -->|{{#ifeq: {{{places|8}}} | 0 | ||
| − | + | <!-- -->|{{#switch: {{{round|no}}} | |
| − | + | <!-- -->|yes = 3 | |
| − | + | <!-- -->|y = 3 | |
| − | + | <!-- -->|true = 3 | |
| − | + | <!-- -->|#default = 2 | |
| − | + | <!-- --> }} | |
| − | + | <!-- -->|{{#switch: {{{round|no}}} | |
| − | + | <!-- -->|yes = {{Str left|2.71828182845904523536028747135266249775724709369995|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | |
|2.718281828459045235360287471352662497757247093699959|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | |2.718281828459045235360287471352662497757247093699959|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| − | + | <!-- -->|y = {{Str left|2.71828182845904523536028747135266249775724709369995|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | |
|2.718281828459045235360287471352662497757247093699959|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | |2.718281828459045235360287471352662497757247093699959|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| − | + | <!-- -->|true = {{Str left|2.71828182845904523536028747135266249775724709369995|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | |
|2.718281828459045235360287471352662497757247093699959|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | |2.718281828459045235360287471352662497757247093699959|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| − | + | <!-- -->|#default = {{Str left|2.718281828459045235360287471352662497757247093699959|{{#expr: {{{places|8}}} + 2}}}} | |
| − | + | <!-- --> }} | |
| − | + | <!-- --> }} | |
| − | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be | + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} |
<!-- --> }} | <!-- --> }} | ||
<!-- --> }} | <!-- --> }} | ||
| Line 70: | Line 61: | ||
|true = <span class="texhtml mvar" style="font-style:italic;">[[e (mathematical constant)|e]]</span> | |true = <span class="texhtml mvar" style="font-style:italic;">[[e (mathematical constant)|e]]</span> | ||
|#default = <span class="texhtml mvar" style="font-style:italic;">e</span> | |#default = <span class="texhtml mvar" style="font-style:italic;">e</span> | ||
| + | }} | ||
| + | }} | ||
| + | |tau = {{#switch: {{{2|value}}} | ||
| + | |value = {{#ifexpr: {{{places|8}}} > 50 | ||
| + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} | ||
| + | <!-- -->|{{#ifexpr: {{{places|8}}} < 0 | ||
| + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} | ||
| + | <!-- -->|{{#ifeq: {{mod|{{{places|8}}}|1}} | 0 | ||
| + | <!-- -->|{{#ifeq: {{{places|8}}} | 0 | ||
| + | <!-- -->|6 | ||
| + | <!-- -->|{{#switch: {{{round|no}}} | ||
| + | <!-- -->|yes = {{Str left|6.28318530717958647692528676655900576839433879875021|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | ||
| + | |6.283185307179586476925286766559005768394338798750211|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| + | <!-- -->|y = {{Str left|6.28318530717958647692528676655900576839433879875021|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | ||
| + | |6.283185307179586476925286766559005768394338798750211|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| + | <!-- -->|true = {{Str left|6.28318530717958647692528676655900576839433879875021|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | ||
| + | |6.283185307179586476925286766559005768394338798750211|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| + | <!-- -->|#default = {{Str left|6.283185307179586476925286766559005768394338798750211|{{#expr: {{{places|8}}} + 2}}}} | ||
| + | <!-- --> }} | ||
| + | <!-- --> }} | ||
| + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} | ||
| + | <!-- --> }} | ||
| + | <!-- --> }} | ||
| + | }} | ||
| + | |symbol = {{#switch: {{{link|no}}} | ||
| + | |yes = [[Turn_(geometry)#Tau_proposals|{{tau}}]] | ||
| + | |y = [[Turn_(geometry)#Tau_proposals|{{tau}}]] | ||
| + | |true = [[Turn_(geometry)#Tau_proposals|{{tau}}]] | ||
| + | |#default = {{tau}} | ||
| + | }} | ||
| + | }} | ||
| + | |phi = {{#switch: {{{2|value}}} | ||
| + | |value = {{#ifexpr: {{{places|8}}} > 50 | ||
| + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} | ||
| + | <!-- -->|{{#ifexpr: {{{places|8}}} < 0 | ||
| + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} | ||
| + | <!-- -->|{{#ifexpr: {{mod|{{{places|8}}}|1}} = 0 | ||
| + | <!-- -->|{{#ifeq: {{{places|8}}} | 0 | ||
| + | <!-- -->|{{#switch: {{{round|no}}} | ||
| + | <!-- -->|yes = 2 | ||
| + | <!-- -->|y = 2 | ||
| + | <!-- -->|true = 2 | ||
| + | <!-- -->|#default = 1 | ||
| + | <!-- --> }} | ||
| + | <!-- -->|{{#switch: {{{round|no}}} | ||
| + | <!-- -->|yes = {{Str left|1.61803398874989484820458683436563811772030917980576|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | ||
| + | |1.618033988749894848204586834365638117720309179805762|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| + | <!-- -->|y = {{Str left|1.61803398874989484820458683436563811772030917980576|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | ||
| + | |1.618033988749894848204586834365638117720309179805762|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| + | <!-- -->|true = {{Str left|1.61803398874989484820458683436563811772030917980576|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | ||
| + | |1.618033988749894848204586834365638117720309179805762|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| + | <!-- -->|#default = {{Str left|1.618033988749894848204586834365638117720309179805762|{{#expr: {{{places|8}}} + 2}}}} | ||
| + | <!-- --> }} | ||
| + | <!-- --> }} | ||
| + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} | ||
| + | <!-- --> }} | ||
| + | <!-- --> }} | ||
| + | }} | ||
| + | |symbol = {{#switch: {{{link|no}}} | ||
| + | |yes = [[Golden ratio|{{phi}}]] | ||
| + | |y = [[Golden ratio|{{phi}}]] | ||
| + | |true = [[Golden ratio|{{phi}}]] | ||
| + | |#default = {{phi}} | ||
| + | }} | ||
| + | }} | ||
| + | |i = {{#switch: {{{2|value}}} | ||
| + | |value = √<span style="border-top:1px solid; padding:0 0.1em;">-1</span> | ||
| + | |symbol = {{#switch: {{{link|no}}} | ||
| + | |yes = <span class="texhtml mvar" style="font-style:italic;">[[Imaginary unit|i]]</span> | ||
| + | |y = <span class="texhtml mvar" style="font-style:italic;">[[Imaginary unit|i]]</span> | ||
| + | |true = <span class="texhtml mvar" style="font-style:italic;">[[Imaginary unit|i]]</span> | ||
| + | |#default = <span class="texhtml mvar" style="font-style:italic;">i</span> | ||
}} | }} | ||
}} | }} | ||
|root2 = {{#switch: {{{2|value}}} | |root2 = {{#switch: {{{2|value}}} | ||
| − | |value = {{#ifexpr: {{{places|8}}} > | + | |value = {{#ifexpr: {{{places|8}}} > 50 |
| − | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be | + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} |
<!-- -->|{{#ifexpr: {{{places|8}}} < 0 | <!-- -->|{{#ifexpr: {{{places|8}}} < 0 | ||
| − | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be | + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} |
<!-- -->|{{#ifexpr: {{mod|{{{places|8}}}|1}} = 0 | <!-- -->|{{#ifexpr: {{mod|{{{places|8}}}|1}} = 0 | ||
| − | <!-- -->|{{ | + | <!-- -->|{{#ifeq: {{{places|8}}} | 0 |
| − | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be | + | <!-- -->|1 |
| + | <!-- -->|{{#switch: {{{round|no}}} | ||
| + | <!-- -->|yes = {{Str left|1.41421356237309504880168872420969807856967187537694|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | ||
| + | |1.414213562373095048801688724209698078569671875376948|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| + | <!-- -->|y = {{Str left|1.41421356237309504880168872420969807856967187537694|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | ||
| + | |1.414213562373095048801688724209698078569671875376948|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| + | <!-- -->|true = {{Str left|1.41421356237309504880168872420969807856967187537694|{{#expr: {{{places|8}}} + 1}}}}{{Str left|{{#expr:{{str rightc|{{Str left | ||
| + | |1.414213562373095048801688724209698078569671875376948|{{#expr: {{{places|8}}} + 3}}}}|2}} round -1}}|1}} | ||
| + | <!-- -->|#default = {{Str left|1.414213562373095048801688724209698078569671875376948|{{#expr: {{{places|8}}} + 2}}}} | ||
| + | <!-- --> }} | ||
| + | <!-- --> }} | ||
| + | <!-- -->|{{error|message=Error: Parameter {{para|places}} (Your input {{{places}}}) must be an integer between 0 and 50}} | ||
<!-- --> }} | <!-- --> }} | ||
<!-- --> }} | <!-- --> }} | ||
Revision as of 02:14, 25 May 2018
Description
Will display either the value of or the symbol of a maths constant chosen by the user.
Parameters
{{constant | {{{1}}} | {{{2}}} | places= | round= | link=}}
|{{{1}}}
- Required. Defines which constant to display.
- Possible Values: e; pi; tau; root2; phi; plastic; i;
|{{{2}}}
- Suggested. Defines whether to display the value of the constant or the symbol.
- Possible Values: symbol; value; Default: value
|places=
- Suggested. Defines the number of decimal places to display. Ignored if displaying symbol.
- Possible Values: Any integer from 0 to 50; Default: 8
|round=
- Choose whether or not to round when picking number of decimal places.
- Possible Values: true; yes; y; Default: false
|link=
- Choose whether or not to turn the symbol into a wiki-link that leads to the constants' respective pages. Ignored if displaying value.
- Possible Values: true; yes; y; Default: false
Examples
| Code | Output | Notes | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
i has no decimal value, so it gets displayed as √-1 | |||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
All links lead to their respective pages | |||||||||||||||||||||
|
|
|
TemplateData
The following section has been automatically generated by Wikipedia using TemplateData.
Displays either the value or the symbol for one of seven mathematical constants chosen by user.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Constant Name | 1 | Defines which constant to display.
| String | required |
| Display Type | 2 | Defines whether to display the value of the constant or the symbol.
| String | suggested |
| Places | places | Defines the number of decimal places to display. Ignored if displaying symbol.
| Number | suggested |
| Link | link | Choose whether or not to turn the symbol into a wiki-link that leads to the constants' respective pages. Ignored if displaying value.
| Boolean | optional |
| Round | round | Choose whether or not to round when displaying decimal places.
| Boolean | optional |
| The above documentation is transcluded from Template:Constant/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |