<?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%2Fcompare</id>
	<title>Module:math/compare - 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%2Fcompare"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:math/compare&amp;action=history"/>
	<updated>2026-04-03T19:31:52Z</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/compare&amp;diff=492226&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local math_module = &quot;Module:math&quot;  local function is_NaN(...) 	is_NaN = require(math_module).is_NaN 	return is_NaN(...) end  local function sign(...) 	sign = require(math_module).sign 	return sign(...) end  --[==[ A comparison function for numbers, which returns {true} if {a} sorts before {b}, or otherwise {false}; it can be used as the sort function with {table.sort}.  This function is roughly equivalent to the {&lt;} operator, but contains the following special considerat...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:math/compare&amp;diff=492226&amp;oldid=prev"/>
		<updated>2026-04-01T10:45:56Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local math_module = &amp;quot;Module:math&amp;quot;  local function is_NaN(...) 	is_NaN = require(math_module).is_NaN 	return is_NaN(...) end  local function sign(...) 	sign = require(math_module).sign 	return sign(...) end  --[==[ A comparison function for numbers, which returns {true} if {a} sorts before {b}, or otherwise {false}; it can be used as the sort function with {table.sort}.  This function is roughly equivalent to the {&amp;lt;} operator, but contains the following special considerat...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local math_module = &amp;quot;Module:math&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local function is_NaN(...)&lt;br /&gt;
	is_NaN = require(math_module).is_NaN&lt;br /&gt;
	return is_NaN(...)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function sign(...)&lt;br /&gt;
	sign = require(math_module).sign&lt;br /&gt;
	return sign(...)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
A comparison function for numbers, which returns {true} if {a} sorts before {b}, or otherwise {false}; it can be used as the sort function with {table.sort}.&lt;br /&gt;
&lt;br /&gt;
This function is roughly equivalent to the {&amp;lt;} operator, but contains the following special considerations in accordance with the {{w|IEEE 754}} standard:&lt;br /&gt;
* {{w|NaN}} is sorted as though it has a larger absolute value than infinity ({-NaN &amp;lt; -Inf}; {+Inf &amp;lt; +NaN}).&lt;br /&gt;
* {{w|Signed zero}} is acknowledged, with {-0 &amp;lt; +0}.]==]&lt;br /&gt;
return function(a, b)&lt;br /&gt;
	-- &amp;lt;, &amp;gt; and == canot return true if either `a` or `b` are NaN.&lt;br /&gt;
	if a &amp;lt; b then&lt;br /&gt;
		return true&lt;br /&gt;
	-- Use &amp;gt; then == instead of &amp;gt;=, so that the ±0 check is only done when `a`&lt;br /&gt;
	-- and `b` are equal.&lt;br /&gt;
	elseif a &amp;gt; b then&lt;br /&gt;
		return false&lt;br /&gt;
	elseif a == b then&lt;br /&gt;
		-- 1/(+0) is Inf; 1/(-0) is -Inf.&lt;br /&gt;
		return a == 0 and b == 0 and 1 / a &amp;lt; 1 / b or false&lt;br /&gt;
	-- One or both must be NaN, and NaN is the only number that returns false&lt;br /&gt;
	-- to a self-equality check, so if `a` == `a` then `b` is NaN (and vice-&lt;br /&gt;
	-- versa). -NaN sorts before everything and +NaN after everything, so the&lt;br /&gt;
	-- sign determines the result.&lt;br /&gt;
	elseif not is_NaN(a) then -- `b` is NaN&lt;br /&gt;
		return sign(b) == 1&lt;br /&gt;
	elseif not is_NaN(b) then -- `a` is NaN&lt;br /&gt;
		return sign(a) == -1&lt;br /&gt;
	end&lt;br /&gt;
	-- If both are NaN, only return true if `a` is -NaN and `b` is +NaN.&lt;br /&gt;
	return sign(a) &amp;lt; sign(b)&lt;br /&gt;
end&lt;/div&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
</feed>