މޮޑިއުލް:Gapnum/doc: Difference between revisions

Content deleted Content added
Created page with "This module is used by {{tl|val}}. == Use in other modules == ===gaps=== The <code>gaps</code> function can be useful for formatting in other modules that work..."
 
m Bot: Replace deprecated <source> tag and "enclose" parameter; cosmetic changes
 
ފޮޅުވަތް 2:
 
== Use in other modules ==
=== gaps ===
The <code>gaps</code> function can be useful for [[MOS:DIGITS|formatting]] in other modules that work with displaying large numbers.
 
<sourcesyntaxhighlight lang="lua">
local gaps = require('Module:Gapnum').gaps
</syntaxhighlight>
</source>
 
Using the <code>gaps</code> 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:
ފޮޅުވަތް 15:
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 <code>tostring()</code> may be required when used in other modules.
 
<sourcesyntaxhighlight lang="lua">
local gaps = require('Module:Gapnum').gaps
 
ފޮޅުވަތް 47:
local n_small_10 = gaps(n, {gap='1px', prec=10})
end
</syntaxhighlight>
</source>
 
=== groups ===
The <code>groups</code> function can be used in other modules to separate a number into groups as <code>gaps</code> does, but instead of a formatted <code>string</code>, the function will return tables whose elements are the separated groups.
 
<sourcesyntaxhighlight lang="lua">
local groups = require('Module:Gapnum').groups
 
ފޮޅުވަތް 83:
local n4a,n4b = groups(123.4567,8)
end
</syntaxhighlight>
</source>