<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.perfecttower2.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AFormatNumber%2Fdoc</id>
	<title>Module:FormatNumber/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.perfecttower2.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AFormatNumber%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://wiki.perfecttower2.com/w/index.php?title=Module:FormatNumber/doc&amp;action=history"/>
	<updated>2026-10-07T07:06:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.perfecttower2.com/w/index.php?title=Module:FormatNumber/doc&amp;diff=4324&amp;oldid=prev</id>
		<title>Speedybrain: Documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.perfecttower2.com/w/index.php?title=Module:FormatNumber/doc&amp;diff=4324&amp;oldid=prev"/>
		<updated>2026-10-07T01:41:23Z</updated>

		<summary type="html">&lt;p&gt;Documentation&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Formats numbers as the game does. It backs [[Template:Number|&amp;lt;nowiki&amp;gt;{{Number}}&amp;lt;/nowiki&amp;gt;]] and, through it, [[Template:Cost|&amp;lt;nowiki&amp;gt;{{Cost}}&amp;lt;/nowiki&amp;gt;]]. [[Module:UI]] (crafting cost) and [[Module:ModuleView]] (full view) call it directly.&lt;br /&gt;
&lt;br /&gt;
Numbers below a million show in full, with thousands separators (&amp;lt;code&amp;gt;120,000&amp;lt;/code&amp;gt;). Larger numbers show as scientific notation (&amp;lt;code&amp;gt;1.2E7&amp;lt;/code&amp;gt;) or as named numbers (&amp;lt;code&amp;gt;12 M&amp;lt;/code&amp;gt;); the reader picks under &amp;#039;&amp;#039;&amp;#039;Appearance &amp;gt; Numbers&amp;#039;&amp;#039;&amp;#039;, and scientific notation is the default. The module writes both forms, in &amp;lt;code&amp;gt;span.wiki-num__sci&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;span.wiki-num__named&amp;lt;/code&amp;gt;, and [[MediaWiki:Common.css]] shows the one the reader picked. Each form has the other in its tooltip. The E is uppercase, as in the game, inside the brand kit class &amp;lt;code&amp;gt;.tpt-num__e&amp;lt;/code&amp;gt;, which sets it smaller than the digits. Page previews (TextExtracts) leave out the named form. &amp;lt;code&amp;gt;inf&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Infinity&amp;lt;/code&amp;gt; show as Infinity.&lt;br /&gt;
&lt;br /&gt;
== Entry points ==&lt;br /&gt;
* &amp;lt;code&amp;gt;main(frame)&amp;lt;/code&amp;gt;: for the template. It reads the arguments of the invoke, or else of the calling template: &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; (the number; thousands separators and &amp;lt;code&amp;gt;1e7&amp;lt;/code&amp;gt; notation work, and anything that isn&amp;#039;t a number comes back unchanged), &amp;lt;code&amp;gt;format&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;prefix&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;suffix&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sortkey&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;icon&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;iconpos&amp;lt;/code&amp;gt;. The result is wrapped in a span with &amp;lt;code&amp;gt;data-sort-value&amp;lt;/code&amp;gt;, for sortable tables.&lt;br /&gt;
* &amp;lt;code&amp;gt;format(value, prefix, suffix, icon, iconPos, format)&amp;lt;/code&amp;gt;: for other modules. &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; must be a number; it isn&amp;#039;t checked. &amp;lt;code&amp;gt;format&amp;lt;/code&amp;gt; set to &amp;lt;code&amp;gt;named&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;scientific&amp;lt;/code&amp;gt; forces one form for every reader, with the other in an &amp;lt;code&amp;gt;abbr&amp;lt;/code&amp;gt; tooltip. &amp;lt;code&amp;gt;icon&amp;lt;/code&amp;gt; follows the number, or comes before it with &amp;lt;code&amp;gt;iconPos = &amp;quot;left&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local formatNumber = require(&amp;#039;Module:FormatNumber&amp;#039;).format&lt;br /&gt;
formatNumber(1.8e12, nil, &amp;#039;%&amp;#039;) -- 1.8E12% or 1.8 T%, as the reader chose&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
&amp;lt;!-- Categories below this line --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Module documentation pages]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Speedybrain</name></author>
	</entry>
</feed>