<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Amath</id>
	<title>Module:math - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Amath"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:math&amp;action=history"/>
	<updated>2026-05-18T15:31:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:math&amp;diff=494840&amp;oldid=prev</id>
		<title>Sware: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:math&amp;diff=494840&amp;oldid=prev"/>
		<updated>2026-04-21T11:22:45Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:22, 21 April 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:math&amp;diff=462416&amp;oldid=prev</id>
		<title>Sware at 11:29, 10 July 2025</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:math&amp;diff=462416&amp;oldid=prev"/>
		<updated>2025-07-10T11:29:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:29, 10 July 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:math&amp;diff=494839&amp;oldid=prev</id>
		<title>wikt&gt;Theknightwho: Optimise to_integer.</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:math&amp;diff=494839&amp;oldid=prev"/>
		<updated>2025-05-07T08:22:38Z</updated>

		<summary type="html">&lt;p&gt;Optimise to_integer.&lt;/p&gt;
&lt;a href=&quot;https://linguifex.com/w/index.php?title=Module:math&amp;amp;diff=494839&amp;amp;oldid=410294&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>wikt&gt;Theknightwho</name></author>
	</entry>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:math&amp;diff=410294&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local export = {}  local format = string.format local is_integer -- defined as export.is_integer below local log = math.log local log10 = math.log10 local select = select local tonumber = tonumber local tostring = tostring local type = type  --[==[ Returns true if the given value is a finite real number, or false if not.]==] function export.is_finite_real_number(n) 	return n and type(n) == &quot;number&quot; and n - n == 0 -- INF, -INF and NAN fail here. end  --[==[ Returns true i...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:math&amp;diff=410294&amp;oldid=prev"/>
		<updated>2025-01-08T12:42:42Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local export = {}  local format = string.format local is_integer -- defined as export.is_integer below local log = math.log local log10 = math.log10 local select = select local tonumber = tonumber local tostring = tostring local type = type  --[==[ Returns true if the given value is a finite real number, or false if not.]==] function export.is_finite_real_number(n) 	return n and type(n) == &amp;quot;number&amp;quot; and n - n == 0 -- INF, -INF and NAN fail here. end  --[==[ Returns true i...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local export = {}&lt;br /&gt;
&lt;br /&gt;
local format = string.format&lt;br /&gt;
local is_integer -- defined as export.is_integer below&lt;br /&gt;
local log = math.log&lt;br /&gt;
local log10 = math.log10&lt;br /&gt;
local select = select&lt;br /&gt;
local tonumber = tonumber&lt;br /&gt;
local tostring = tostring&lt;br /&gt;
local type = type&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Returns true if the given value is a finite real number, or false if not.]==]&lt;br /&gt;
function export.is_finite_real_number(n)&lt;br /&gt;
	return n and type(n) == &amp;quot;number&amp;quot; and n - n == 0 -- INF, -INF and NAN fail here.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Returns true if the given value is an integer, or false if not.]==]&lt;br /&gt;
function export.is_integer(n)&lt;br /&gt;
	return n and type(n) == &amp;quot;number&amp;quot; and n % 1 == 0 -- INF, -INF and NAN also fail here.&lt;br /&gt;
end&lt;br /&gt;
is_integer = export.is_integer&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Returns true if the given value is a positive integer (or zero if the `include_0` flag is set), or false if not.]==]&lt;br /&gt;
function export.is_positive_integer(n, include_0)&lt;br /&gt;
	return is_integer(n) and (n &amp;gt; 0 or include_0 and n == 0) or false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Returns the base-10 logarithm of `x`.&lt;br /&gt;
&lt;br /&gt;
Should be used instead of `math.log10`, which is deprecated and may stop working&lt;br /&gt;
if Scribunto is updated to a more recent Lua version.]==]&lt;br /&gt;
function export.log10(x)&lt;br /&gt;
	if log10 == nil then&lt;br /&gt;
		if log(10, 10) == 1 then -- Lua 5.2&lt;br /&gt;
			function log10(x)&lt;br /&gt;
				return log(x, 10)&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			function log10(x)&lt;br /&gt;
				return log(x) * 0.43429448190325182765112891891660508229439700580367 -- log10(e)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	export.log10 = log10&lt;br /&gt;
end&lt;br /&gt;
export.log10() -- Sets the actual returned function. Structured like this so that module documentation works.&lt;br /&gt;
&lt;br /&gt;
local function integer_error(x, param, func_name)&lt;br /&gt;
	local type_x = type(x)&lt;br /&gt;
	error(format(&lt;br /&gt;
		&amp;quot;bad argument #%d to &amp;#039;%s&amp;#039; (integer expected, got %s)&amp;quot;,&lt;br /&gt;
		param, func_name, type_x == &amp;quot;number&amp;quot; and tostring(x) or type_x&lt;br /&gt;
	), 3)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Converts a decimal number to hexadecimal.]==]&lt;br /&gt;
function export.to_hex(dec)&lt;br /&gt;
	dec = tonumber(dec) or dec&lt;br /&gt;
	if not is_integer(dec, true) then&lt;br /&gt;
		integer_error(dec, 1, &amp;quot;to_hex&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	local neg = dec &amp;lt; 0&lt;br /&gt;
	if neg then&lt;br /&gt;
		dec = -dec&lt;br /&gt;
	end&lt;br /&gt;
	-- Inputs &amp;gt;= 2^64 cause string.format to return &amp;quot;0&amp;quot;.&lt;br /&gt;
	if dec &amp;gt;= 18446744073709551616 then&lt;br /&gt;
		error(&amp;quot;integer overflow in &amp;#039;to_hex&amp;#039;: cannot convert inputs with a magnitude greater than or equal to 2^64 (18446744073709551616)&amp;quot;, 2)&lt;br /&gt;
	end&lt;br /&gt;
	-- string.format treats hex numbers as unsigned, so any sign must be added manually.&lt;br /&gt;
	return format(&amp;quot;%s%X&amp;quot;, neg and &amp;quot;-&amp;quot; or &amp;quot;&amp;quot;, dec)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Returns the greatest common divisor.]==]&lt;br /&gt;
function export.gcd(n, ...)&lt;br /&gt;
	n = tonumber(n) or n&lt;br /&gt;
	if not is_integer(n) then&lt;br /&gt;
		integer_error(n, 1, &amp;quot;gcd&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	local q, args_len, integers = ..., select(&amp;quot;#&amp;quot;, ...)&lt;br /&gt;
	-- Compute p_1 = gcd(n_1, n_2), p_2 = gcd(p_1, n_3), ... i.e. compute GCD by Euclid&amp;#039;s algorithm for the current result and the next number.&lt;br /&gt;
	for i = 2, args_len + 1 do&lt;br /&gt;
		q = tonumber(q) or q&lt;br /&gt;
		if not is_integer(q) then&lt;br /&gt;
			integer_error(q, i, &amp;quot;gcd&amp;quot;)&lt;br /&gt;
		elseif n ~= 1 then -- If n is 1, validate remaining inputs.&lt;br /&gt;
			-- GCD of two integers n, q with Euclid&amp;#039;s algorithm.&lt;br /&gt;
			while q ~= 0 do&lt;br /&gt;
				n, q = q, n % q&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if i &amp;lt;= args_len then&lt;br /&gt;
			-- Only create a table if absolutely necessary, as it&amp;#039;s inefficient.&lt;br /&gt;
			if i == 2 then&lt;br /&gt;
				integers = {...}&lt;br /&gt;
			end&lt;br /&gt;
			q = integers[i]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return n &amp;lt; 0 and -n or n&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Returns the least common multiple.]==]&lt;br /&gt;
function export.lcm(n, ...)&lt;br /&gt;
	n = tonumber(n) or n&lt;br /&gt;
	if not is_integer(n) then&lt;br /&gt;
		integer_error(n, 1, &amp;quot;lcm&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	local q, args_len, integers = ..., select(&amp;quot;#&amp;quot;, ...)&lt;br /&gt;
	-- Compute the product of all inputs as p and GCD as n.&lt;br /&gt;
	for i = 2, args_len + 1 do&lt;br /&gt;
		q = tonumber(q) or q&lt;br /&gt;
		if not is_integer(q) then&lt;br /&gt;
			integer_error(q, i, &amp;quot;lcm&amp;quot;)&lt;br /&gt;
		elseif n ~= 0 then  -- If n is 0, validate remaining inputs.&lt;br /&gt;
			-- Compute the product.&lt;br /&gt;
			local p = n * q&lt;br /&gt;
			-- GCD of two integers n, q with Euclid&amp;#039;s algorithm.&lt;br /&gt;
			while q ~= 0 do&lt;br /&gt;
				n, q = q, n % q&lt;br /&gt;
			end&lt;br /&gt;
			-- Divide product by the GCD to get new LCM.&lt;br /&gt;
			n = p / n&lt;br /&gt;
		end&lt;br /&gt;
		if i &amp;lt;= args_len then&lt;br /&gt;
			-- Only create a table if absolutely necessary, as it&amp;#039;s inefficient.&lt;br /&gt;
			if i == 2 then&lt;br /&gt;
				integers = {...}&lt;br /&gt;
			end&lt;br /&gt;
			q = integers[i]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return n &amp;lt; 0 and -n or n&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
</feed>