lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On my system "%04x" works perfectly fine. You'll have to give it a length or it won't need to prefix with zeroes.

Kaj


On Sun, Jun 2, 2013 at 2:31 AM, <meino.cramer@gmx.de> wrote:
Hi,

I have to convert *a lot* of decimal numbers, given textually in a
ASCII file into hexadecimal.

The conversion itself is not the problem ("io.write(string.format(
"%X",....))").

But the hexadecimal number have to have leading zeroes...

The format "%X" seems not to support leading zeroes as in C....

How can I accomplish this with not too much overhead with lua 5.1x ?

Thank you very much in advance for any help!
Best regards,
mcc