This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
here in line1 4 zeroes are padded. But line2 only 3.
In case of decimal, isnt + sign counted as part of the width?
You are completely wrong here Abhi, in line1 output is:
here no zero padded, as zero padding is done on left side not right side, by default %f shows 6 fractional digits, means 6 digits after a decimal point, so 8 place is already exhausted by %f, so no need to pad any zero on the left side.
In second case it is %d so it will show only +1234 that already took 5 places as + is counted in width, so %+08d will pad only 3 zeros on the left side.