Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

combine string.format arguments

I want to generate a 4 character hex number.

To generate a hex number you can use

string.format("{0:X}", number) 

and to generate a 4 char string you can use

string.format("{0:0000}", number)

Is there any way to combine them?

like image 518
dcarneiro Avatar asked Apr 26 '26 17:04

dcarneiro


1 Answers

I'm assuming you mean: 4-digit hexadecimal number.

If so, then yes:

string.Format("{0:X4}", number)

should do the trick.

like image 88
Lasse V. Karlsen Avatar answered Apr 29 '26 06:04

Lasse V. Karlsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!