bug with sprintf adding leading zeros

Jun 3, 2008 at 4:58am

bug with sprintf adding leading zeros

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.

#38217
Jun 3, 2008 at 5:11am

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.

#132927
Jun 3, 2008 at 5:14am

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

#132928
Jun 3, 2008 at 5:15am

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

cheers,
Danjel

#132929
Jun 4, 2008 at 1:03pm

#132930

You must be logged in to reply to this topic.