Template:Datacalc/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(12 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{Doc/subpage}}
{{Doc/subpage}}
 
<div style="display:flex;"><div style="flex:1;">
{{infobox template
This template interprets a numbered input string (in bytes) and converts it into a specified output filesize. ''For a logical use-case, see [[Template:Infobox template]]''.
| summary      = Converts a filesize string
| type        = Mathematics template
| contrib      = [[User:mailmanmicky|mailmanmicky]]
| creationdate = 02/06/2023<br><small>(02 June 2022)</small>
| translation  = No
| parser      = Yes
| var          = No
}}
 
This template interprets a numbered input string in bytes and converts it into a specified output filesize. ''For a logical use-case, see [[Template:Infobox template]]''.


== Copy and Paste ==
== Copy and Paste ==
{{CodeBlock|<nowiki>{{Infobox
{{CodeBlock|<nowiki>{{Datacalc
| 1 =  
| 1 =  
| output =
| output =
Line 22: Line 12:
{{CodeBlock|<nowiki>{{Datacalc}}</nowiki>}}
{{CodeBlock|<nowiki>{{Datacalc}}</nowiki>}}


{|class="standard-table" | style="text-align:center; width:auto;"
{|class="standard-table" | style="text-align:center; width:100%;"
|-
|-
! style="width:15%;" | {{Dictionary/common|Param}}
! Parameter
! style="width:20%;" | {{Dictionary/common|Desc}}
! Description
! style="width:40%;" | {{Dictionary/common|Example}}
! Example
! style="width:35%;" | {{Dictionary/common|Preview}}
! Preview
|-
| ''No parameters''
| Template defaults to displaying 0 bytes
| {{CodeBlock|margin=5px|N/A}}
| {{datacalc}}
|-
|-
| {{param|1}}
| {{param|1}}
Line 34: Line 29:
| {{datacalc|1000}}
| {{datacalc|1000}}
|-
|-
| {{param|output}}
| {{param|id}}
| Input filesize, i.e.: kilobytes.
| Specifies what to do with the identifier.
| {{CodeBlock|margin=5px|<nowiki>| output = kb </nowiki>}}
| {{CodeBlock|margin=5px 5px 0 5px|<nowiki>| id = abbreviate </nowiki>}}<br>{{CodeBlock|margin=0 5px 5px 5px|<nowiki>| id = none </nowiki>}}
| {{datacalc|1000|output=kb}}
| {{datacalc|1000|id=abbreviate}}<br>{{datacalc|1000|id=none}}
|-
|-
| {{param|prefix}}
| {{param|prefix}}
| Unit prefix; used to determine exponential power.
| Unit prefix; determinant for exponential power.
| {{CodeBlock|margin=5px|<nowiki>| prefix = binary </nowiki>}}
| {{CodeBlock|margin=5px|<nowiki>| prefix = binary </nowiki>}}
| {{datacalc|1000|output=kb|prefix=binary}}
| {{datacalc|1000|output=kb|prefix=binary}}
|-
|-
| {{param|round}}
| {{param|round}}
| Used to round up the output string
| Used to round up the output string to the specified power.
| {{CodeBlock|margin=5px|<nowiki>| round = 2 </nowiki>}}
| {{CodeBlock|margin=5px|<nowiki>| round = 2 </nowiki>}}
| {{datacalc|1000|output=kb|prefix=binary|round=2}}
| {{datacalc|1000|output=kb|prefix=binary|round=2}}
|-
| {{param|output}}
| Output filesize, i.e.: kilobytes.
| {{CodeBlock|margin=5px|<nowiki>| output = kb </nowiki>}}
| {{datacalc|1000|output=kb}}
|-
|-
|}
|}


{{clr}}
== Examples ==
<div style="background:#232323; border-radius:.5em; padding:1em; display:grid; grid-template-columns:1fr 1fr; justify-items:center;">
<div>
'''Non-exponential input'''<br>
{{datacalc|1000|output=kb}}<br>{{code|{{tint|color=comment|input:}} <nowiki>{{datacalc|1000|output=kb}}</nowiki>}}


{{Doc/Sandbox other|
 
[[Category:Mathematics templates]]
'''Non-exponential input by the second power'''<br>
{{datacalc|1000|output=kb|prefix=binary}}<br>{{code|{{tint|color=comment|input:}} <nowiki>{{datacalc|1000|output=kb|prefix=binary}}</nowiki>}}
 
 
'''Exponential input'''<br>
{{datacalc|10^3|output=kb}}<br>{{code|{{tint|color=comment|input:}} <nowiki>{{datacalc|10^3|output=kb}}</nowiki>}}
 
 
'''Exponential input by the second power'''<br>
{{datacalc|10^3|output=kb|prefix=binary}}<br>{{code|{{tint|color=comment|input:}} <nowiki>{{datacalc|10^3|output=kb|prefix=binary}}</nowiki>}}
</div>
 
<div>
'''Filesize with the unit identifier abbreviated'''<br>
{{datacalc|1000|output=kb|id=abbreviate}}<br>{{code|{{tint|color=comment|input:}} <nowiki>{{datacalc|1000|output=kb|id=abbreviate}}</nowiki>}}
 
 
'''Filesize without the unit identifier'''<br>
{{datacalc|1000|output=kb|id=none}}<br>{{code|{{tint|color=comment|input:}} <nowiki>{{datacalc|1000|output=kb|id=none}}</nowiki>}}
 
 
'''Rounded up to 1<sup>1/2</sup> power'''<br>
{{datacalc|1000|output=kb|prefix=binary|round=1.5}}<br>{{code|{{tint|color=comment|input:}} <nowiki>{{datacalc|1000|output=kb|prefix=binary|round=1.5}}</nowiki>}}
 
 
'''Rounded up to the second power'''<br>
{{datacalc|1000|output=kb|prefix=binary|round=2}}<br>{{code|{{tint|color=comment|input:}} <nowiki>{{datacalc|1000|output=kb|prefix=binary|round=2}}</nowiki>}}
</div>
 
</div></div>
 
<div>
{{infobox template
| summary      = Converts a filesize string
| type        = Mathematics template
| contrib      = [[User:mailmanmicky|mailmanmicky]]
| creationdate = 02/06/2023<br><small>(02 June 2022)</small>
| translation  = No
| parser      = Yes
| var          = No
}}
}}
</div></div>

Latest revision as of 04:47, 4 June 2023

Edit-copy.png
This is a documentation subpage for Template:Datacalc.
Don't forget to purge the contents of the base page upon creating or editing this subpage.

This template interprets a numbered input string (in bytes) and converts it into a specified output filesize. For a logical use-case, see Template:Infobox template.

Copy and Paste

{{Datacalc | 1 = | output = }}

Usage & Preview

{{Datacalc}}
Parameter Description Example Preview
No parameters Template defaults to displaying 0 bytes
N/A
0 bytes
{{{1}}} Input string, interpreted by default as bytes.
| 1 = 1000
1000 bytes
{{{id}}} Specifies what to do with the identifier.
| id = abbreviate

| id = none
1000 B
1000
{{{prefix}}} Unit prefix; determinant for exponential power.
| prefix = binary
0.9765625 kibibytes
{{{round}}} Used to round up the output string to the specified power.
| round = 2
0.98 kibibytes
{{{output}}} Output filesize, i.e.: kilobytes.
| output = kb
1 kilobytes

Examples

Non-exponential input
1 kilobytes
input: {{datacalc|1000|output=kb}}


Non-exponential input by the second power
0.9765625 kibibytes
input: {{datacalc|1000|output=kb|prefix=binary}}


Exponential input
1 kilobytes
input: {{datacalc|10^3|output=kb}}


Exponential input by the second power
0.9765625 kibibytes
input: {{datacalc|10^3|output=kb|prefix=binary}}

Filesize with the unit identifier abbreviated
1 kB
input: {{datacalc|1000|output=kb|id=abbreviate}}


Filesize without the unit identifier
1
input: {{datacalc|1000|output=kb|id=none}}


Rounded up to 11/2 power
1 kibibytes
input: {{datacalc|1000|output=kb|prefix=binary|round=1.5}}


Rounded up to the second power
0.98 kibibytes
input: {{datacalc|1000|output=kb|prefix=binary|round=2}}

Template:Datacalc
Logo-template.png
Summary
Converts a filesize string
Type
Mathematics template
Contributors
Creation date
02/06/2023
(02 June 2022)
Notes
N/A
Subpages
Documentation
Preload
N/A
Sandbox
N/A
Strings
N/A
Testcases
N/A
Other
N/A
Revision information
Latest editor
THE OWL
Last edited
04/06/2023
20230604044740
Revision size
3510 bytes
3.51 kilobytes
0.00351 megabytes
Technical information
Page identifier
53975
Contains translations
No
Uses parser functions?
Yes
Uses variables?
No