bug with sprintf adding leading zeros


    Jun 03 2008 | 4:58 am
    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.

    • Jun 03 2008 | 5:11 am
      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.
    • Jun 03 2008 | 5:14 am
      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
    • Jun 03 2008 | 5:15 am
      oops replied at the same time as your message arrived. works now!
      cheers,
      Danjel
    • Jun 04 2008 | 1:03 pm