<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=Module%3AGapnum%2Fdoc</id>
	<title>Module:Gapnum/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=Module%3AGapnum%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Module:Gapnum/doc&amp;action=history"/>
	<updated>2026-04-10T11:05:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://pool.calebcooper.ie/index.php?title=Module:Gapnum/doc&amp;diff=12919&amp;oldid=prev</id>
		<title>Caleb Cooper: Created page with &quot;This module is used by {{tl|val}}.  == Use in other modules == ===gaps=== The &lt;code&gt;gaps&lt;/code&gt; function can be useful for formatting in other modules that work...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Module:Gapnum/doc&amp;diff=12919&amp;oldid=prev"/>
		<updated>2020-10-20T15:51:18Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This module is used by {{tl|val}}.  == Use in other modules == ===gaps=== The &amp;lt;code&amp;gt;gaps&amp;lt;/code&amp;gt; function can be useful for &lt;a href=&quot;/index.php?title=MOS:DIGITS&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;MOS:DIGITS (page does not exist)&quot;&gt;formatting&lt;/a&gt; in other modules that work...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This module is used by {{tl|val}}.&lt;br /&gt;
&lt;br /&gt;
== Use in other modules ==&lt;br /&gt;
===gaps===&lt;br /&gt;
The &amp;lt;code&amp;gt;gaps&amp;lt;/code&amp;gt; function can be useful for [[MOS:DIGITS|formatting]] in other modules that work with displaying large numbers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local gaps = require(&amp;#039;Module:Gapnum&amp;#039;).gaps&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the &amp;lt;code&amp;gt;gaps&amp;lt;/code&amp;gt; function, the first argument is the number to format. The second argument can be a table with keys that tell the module how to format. The table keys that can be used are:&lt;br /&gt;
* &amp;lt;code&amp;gt;gap&amp;lt;/code&amp;gt; - a number with CSS units (px, em, en, etc) that define the size of the gap between numbers. If blank, the module will use &amp;lt;code&amp;gt;0.25em&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;prec&amp;lt;/code&amp;gt; - a number that determines the precision of the decimal part of the number. If the precision is less than the number of digits, extra digits will be removed without rounding; if it is more, zeroes will be added to the end to create the desired precision. If blank, the module will use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt;, which means the precision will be the same as the number given; no digits added or removed.&lt;br /&gt;
&lt;br /&gt;
Note that the return statement is a table. This means more styling or text can be added to the wrapper span tag, but it may also mean that &amp;lt;code&amp;gt;tostring()&amp;lt;/code&amp;gt; may be required when used in other modules.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local gaps = require(&amp;#039;Module:Gapnum&amp;#039;).gaps&lt;br /&gt;
&lt;br /&gt;
function example()&lt;br /&gt;
	local n = 123456.78900011&lt;br /&gt;
	-- Example for just simple formatting of a number&lt;br /&gt;
	-- n_gaps will use the default, .25em gaps and no change in precision&lt;br /&gt;
	-- The result will have its gaps created with inline css&lt;br /&gt;
	-- But the result would look like:&lt;br /&gt;
	-- 123 456.789 000 11&lt;br /&gt;
	local n_gaps = gaps(n)&lt;br /&gt;
&lt;br /&gt;
	-- Different gap size&lt;br /&gt;
	-- These will format n into the same groups as above&lt;br /&gt;
	-- But the spaces between the groups will be larger and smaller, respectively&lt;br /&gt;
	local n_big_gaps = gaps(n, {gap=&amp;#039;1em&amp;#039;})&lt;br /&gt;
	local n_small_gaps = gaps(n, {gap=&amp;#039;1px&amp;#039;})&lt;br /&gt;
&lt;br /&gt;
	-- Different precision&lt;br /&gt;
	-- n_prec_5 will use the number 123456.78900&lt;br /&gt;
	-- The result would look like:&lt;br /&gt;
	-- 123 456.789 00&lt;br /&gt;
	local n_prec_5 = gaps(n, {prec=5})&lt;br /&gt;
	-- n_prec_10 will use the number 123456.7890001100&lt;br /&gt;
	-- The result would look like:&lt;br /&gt;
	-- 123 456.789 000 1100&lt;br /&gt;
	local n_prec_10 = gaps(n, {prec=10})&lt;br /&gt;
&lt;br /&gt;
	-- Both different gaps and precision can be used:&lt;br /&gt;
	local n_big_5 = gaps(n, {gap=&amp;#039;1em&amp;#039;, prec=5})&lt;br /&gt;
	local n_small_10 = gaps(n, {gap=&amp;#039;1px&amp;#039;, prec=10})&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===groups===&lt;br /&gt;
The &amp;lt;code&amp;gt;groups&amp;lt;/code&amp;gt; function can be used in other modules to separate a number into groups as &amp;lt;code&amp;gt;gaps&amp;lt;/code&amp;gt; does, but instead of a formatted &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;, the function will return tables whose elements are the separated groups.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local groups = require(&amp;#039;Module:Gapnum&amp;#039;).groups&lt;br /&gt;
&lt;br /&gt;
function example()&lt;br /&gt;
	-- This will return one table:&lt;br /&gt;
	-- {123,456}&lt;br /&gt;
	local n1 = groups(123456)&lt;br /&gt;
&lt;br /&gt;
	-- This will return two tables, each assigned to a different variable:&lt;br /&gt;
	-- n2a will be:&lt;br /&gt;
	-- {1,234}&lt;br /&gt;
	-- n2b will be:&lt;br /&gt;
	-- {567,89}&lt;br /&gt;
	local n2a,n2b = groups(1234.56789)&lt;br /&gt;
&lt;br /&gt;
	-- This will return two tables:&lt;br /&gt;
	-- An integer part is always returned, even if it is 0&lt;br /&gt;
	-- n3a will be:&lt;br /&gt;
	-- {0}&lt;br /&gt;
	-- n3b will be:&lt;br /&gt;
	-- {123,4567}&lt;br /&gt;
	local n3a,n3b = groups(0.1234567)&lt;br /&gt;
&lt;br /&gt;
	-- Just like the other functions, a precision can be defined&lt;br /&gt;
	-- precision is simply the second parameter&lt;br /&gt;
	-- n4a will be:&lt;br /&gt;
	-- {123}&lt;br /&gt;
	-- n4b will be:&lt;br /&gt;
	-- {456,700,00}&lt;br /&gt;
	local n4a,n4b = groups(123.4567,8)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caleb Cooper</name></author>
	</entry>
</feed>