开发者

perl printf: float +1.2 should print as +001.200000

开发者 https://www.devze.com 2023-03-05 09:49 出处:网络
I have tried this: printf(\"%+03.6f\",+1.2开发者_运维技巧); but it gives me +1.200000 what I need is

I have tried this:

printf("%+03.6f",+1.2开发者_运维技巧);

but it gives me

+1.200000

what I need is

+001.200000

Any ideas?


The first number is the total number of characters, so you're asking it to provide minimum 6 digits of precision in a field of size 3 and it expands the width as needed to fit. Try 11 instead (width of your example output).

0

精彩评论

暂无评论...
验证码 换一张
取 消