Module:GetIDEMASectors

From Computing Classics Wiki
Revision as of 00:34, 12 September 2022 by TheDragonFire123 (talk | contribs)

Documentation for this module may be created at Module:GetIDEMASectors/doc

local p = {}

-- Returns the number of IDEMA sectors given a capacity in GB.
function p.getIDEMASectors(gbCapacity, sectorSize)
	-- http://www.idema.org/wp-content/downloads/2169.pdf
	gb50Less = gbCapacity - 50
	
	if (sectorSize == 512 or sectorSize == "512") then
		return math.floor(97696368 + (1953504 * gb50Less))
	elseif (sectorSize == 4096 or sectorSize == "4096" or sectorSize == "4,096") then
		return math.floor(12212046 + (244188 * gb50Less))
	else
		error("getIDEMASectors: Sector size given was not 512 or 4096 (was " .. sectorSize .. ")")
	end
end

-- Main entry point for this module.
function p.invokeMain(frame)
	return p.getIDEMASectors(tonumber(frame.args[1]), frame.args[2])
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.