Title pretty much sums it up; I’ve never really thought about it but what is the different between using d/i or u when string formatting, for example:
print(string.format("The number is %d", 10))
This will print “The number is 10”, but so will:
print(string.format("The number is %u", 10))
So is there a difference between the two?
According to the API reference:
%u -->> Magic character for upper case letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ
%d -->> Magic character for digits (numbers): 0123456789
It considers 10 as an uppercase letter for some odd reason.
About %d and %i, they really seem to do the same thing, they both ignore decimal points.
1 Like
Forummer
(Forummer)
#3
They’re referring to string format options not string patterns.
So is there a difference between the two?
%d%i produce signed outputs, %u produces an unsigned output.
string.format("%d", -10) -- -10
string.format("%i", -10) -- -10
string.format("%u", -10) -- 18446744073709551606
2 Likes