What does the % mean?

so I want to understand what this percentage means

I have went on the roblox hub to learn more about string.format but well in this case the % isn’t inside the 1st argument of string.format and their is not specifier

function Format(Int)
	return string.format("%02i", Int)
end

function convertToHMS(Seconds)
	local Minutes = (Seconds - Seconds%60)/60 --what does the percentage here mean?near the 60
	Seconds = Seconds - Minutes*60
	local Hours = (Minutes - Minutes%60)/60
	Minutes = Minutes - Hours*60
	return Format(Hours)..":"..Format(Minutes)..":"..Format(Seconds)
end
1 Like

In the first function, the ‘%’ denotes a string pattern to format the number into an integer that is padded to the left with zeros to be two characters long.

In the second, the symbol represents the modulus operator. It returns the remainder of two numbers being divided.

6 Likes

It’s the modulus operator – it gives you the remainder of the division.

print(60 % 60) -- prints 0
print(61 % 60) -- prints 1
print(147 % 60) -- prints 27
13 Likes

It’s different in different contexts, you can use it as an escape for “magic” characters or for patterns.

Otherwise known as the modulus operator, it returns the remainder after division

local s = "this is a number: 10"
print(s:match("%d+") % 3) -->1