bug with sprintf adding leading zeros

Danjel van Tijn's icon

I tried this with sprintf:

[sprintf %.3X]

On output it only adds the leading zeros if the resulting hex number has a letter in it (A-F) if it doesn't (e.g. the number '8' or '112' etc.) then it doesn't add the leading zeros.

I attached the patch to check it out.

Chris Muir's icon

Max numbers don't have leading zeros. Max symbols can have leading zeros. When your output has symbol A-F in it it will be output as a symbol, so it will have the leading zero. If you change your sprintf format string to "sprintf symout %.3X" it will always output a symbol.

Danjel van Tijn's icon

further testing shows it only works as long as you put a character or string in front of it.

e.g. sprintf test%.3X works but sprintf %.3X does not

Danjel van Tijn's icon

oops replied at the same time as your message arrived. works now!

cheers,
Danjel

Peter Castine's icon