<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="mobile-web-app-capable" content="yes">
    <title>
        Printf corner cases in std::format - HackMD
    </title>
    <link rel="icon" type="image/png" href="https://hackmd.io/favicon.png">
    <link rel="apple-touch-icon" href="https://hackmd.io/apple-touch-icon.png">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css" integrity="sha256-3iu9jgsy9TpTwXKb7bNQzqWekRX7pPK+2OLj3R922fo=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/octicons/3.5.0/octicons.min.css" integrity="sha256-QiWfLIsCT02Sdwkogf6YMiQlj4NE84MKkzEMkZnMGdg=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/themes/prism.min.css" integrity="sha256-vtR0hSWRc3Tb26iuN2oZHt3KRUomwTufNIf5/4oeCyg=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/emojify.js/1.1.0/css/basic/emojify.min.css" integrity="sha256-UOrvMOsSDSrW6szVLe8ZDZezBxh5IoIfgTwdNDgTjiU=" crossorigin="anonymous" />
    <style>
        @import url(https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i|Source+Code+Pro:300,400,500|Source+Sans+Pro:300,300i,400,400i,600,600i|Source+Serif+Pro&subset=latin-ext);.hljs{display:block;background:#fff;padding:.5em;color:#333;overflow-x:auto}.hljs-comment,.hljs-meta{color:#969896}.hljs-emphasis,.hljs-quote,.hljs-string,.hljs-strong,.hljs-template-variable,.hljs-variable{color:#df5000}.hljs-keyword,.hljs-selector-tag,.hljs-type{color:#a71d5d}.hljs-attribute,.hljs-bullet,.hljs-literal,.hljs-number,.hljs-symbol{color:#0086b3}.hljs-built_in,.hljs-builtin-name{color:#005cc5}.hljs-name,.hljs-section{color:#63a35c}.hljs-tag{color:#333}.hljs-attr,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-selector-pseudo,.hljs-title{color:#795da3}.hljs-addition{color:#55a532;background-color:#eaffea}.hljs-deletion{color:#bd2c00;background-color:#ffecec}.hljs-link{text-decoration:underline}.markdown-body{font-size:16px;line-height:1.5;word-wrap:break-word}.markdown-body:after,.markdown-body:before{display:table;content:""}.markdown-body:after{clear:both}.markdown-body>:first-child{margin-top:0!important}.markdown-body>:last-child{margin-bottom:0!important}.markdown-body a:not([href]){color:inherit;text-decoration:none}.markdown-body .absent{color:#c00}.markdown-body .anchor{float:left;padding-right:4px;margin-left:-20px;line-height:1}.markdown-body .anchor:focus{outline:none}.markdown-body blockquote,.markdown-body dl,.markdown-body ol,.markdown-body p,.markdown-body pre,.markdown-body table,.markdown-body ul{margin-top:0;margin-bottom:16px}.markdown-body hr{height:.25em;padding:0;margin:24px 0;background-color:#e7e7e7;border:0}.markdown-body blockquote{font-size:16px;padding:0 1em;color:#777;border-left:.25em solid #ddd}.markdown-body blockquote>:first-child{margin-top:0}.markdown-body blockquote>:last-child{margin-bottom:0}.markdown-body .loweralpha{list-style-type:lower-alpha}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{margin-top:24px;margin-bottom:16px;font-weight:600;line-height:1.25}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{color:#000;vertical-align:middle;visibility:hidden}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{text-decoration:none}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{visibility:visible}.markdown-body h1 code,.markdown-body h1 tt,.markdown-body h2 code,.markdown-body h2 tt,.markdown-body h3 code,.markdown-body h3 tt,.markdown-body h4 code,.markdown-body h4 tt,.markdown-body h5 code,.markdown-body h5 tt,.markdown-body h6 code,.markdown-body h6 tt{font-size:inherit}.markdown-body h1{font-size:2em}.markdown-body h1,.markdown-body h2{padding-bottom:.3em;border-bottom:1px solid #eee}.markdown-body h2{font-size:1.5em}.markdown-body h3{font-size:1.25em}.markdown-body h4{font-size:1em}.markdown-body h5{font-size:.875em}.markdown-body h6{font-size:.85em;color:#777}.markdown-body ol,.markdown-body ul{padding-left:2em}.markdown-body ol.no-list,.markdown-body ul.no-list{padding:0;list-style-type:none}.markdown-body ol ol,.markdown-body ol ul,.markdown-body ul ol,.markdown-body ul ul{margin-top:0;margin-bottom:0}.markdown-body li>p{margin-top:16px}.markdown-body li+li{margin-top:.25em}.markdown-body dl{padding:0}.markdown-body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:700}.markdown-body dl dd{padding:0 16px;margin-bottom:16px}.markdown-body table{display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}.markdown-body table th{font-weight:700}.markdown-body table td,.markdown-body table th{padding:6px 13px;border:1px solid #ddd}.markdown-body table tr{background-color:#fff;border-top:1px solid #ccc}.markdown-body table tr:nth-child(2n){background-color:#f8f8f8}.markdown-body img{max-width:100%;box-sizing:content-box;background-color:#fff}.markdown-body img[align=right]{padding-left:20px}.markdown-body img[align=left]{padding-right:20px}.markdown-body .emoji{max-width:none;vertical-align:text-top;background-color:transparent}.markdown-body span.frame{display:block;overflow:hidden}.markdown-body span.frame>span{display:block;float:left;width:auto;padding:7px;margin:13px 0 0;overflow:hidden;border:1px solid #ddd}.markdown-body span.frame span img{display:block;float:left}.markdown-body span.frame span span{display:block;padding:5px 0 0;clear:both;color:#333}.markdown-body span.align-center{display:block;overflow:hidden;clear:both}.markdown-body span.align-center>span{display:block;margin:13px auto 0;overflow:hidden;text-align:center}.markdown-body span.align-center span img{margin:0 auto;text-align:center}.markdown-body span.align-right{display:block;overflow:hidden;clear:both}.markdown-body span.align-right>span{display:block;margin:13px 0 0;overflow:hidden;text-align:right}.markdown-body span.align-right span img{margin:0;text-align:right}.markdown-body span.float-left{display:block;float:left;margin-right:13px;overflow:hidden}.markdown-body span.float-left span{margin:13px 0 0}.markdown-body span.float-right{display:block;float:right;margin-left:13px;overflow:hidden}.markdown-body span.float-right>span{display:block;margin:13px auto 0;overflow:hidden;text-align:right}.markdown-body code,.markdown-body tt{padding:0;padding-top:.2em;padding-bottom:.2em;margin:0;font-size:85%;background-color:rgba(0,0,0,.04);border-radius:3px}.markdown-body code:after,.markdown-body code:before,.markdown-body tt:after,.markdown-body tt:before{letter-spacing:-.2em;content:"\00a0"}.markdown-body code br,.markdown-body tt br{display:none}.markdown-body del code{text-decoration:inherit}.markdown-body pre{word-wrap:normal}.markdown-body pre>code{padding:0;margin:0;font-size:100%;word-break:normal;white-space:pre;background:transparent;border:0}.markdown-body .highlight{margin-bottom:16px}.markdown-body .highlight pre{margin-bottom:0;word-break:normal}.markdown-body .highlight pre,.markdown-body pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;background-color:#f7f7f7;border-radius:3px}.markdown-body pre code,.markdown-body pre tt{display:inline;max-width:auto;padding:0;margin:0;overflow:visible;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.markdown-body pre code:after,.markdown-body pre code:before,.markdown-body pre tt:after,.markdown-body pre tt:before{content:normal}.markdown-body .csv-data td,.markdown-body .csv-data th{padding:5px;overflow:hidden;font-size:12px;line-height:1;text-align:left;white-space:nowrap}.markdown-body .csv-data .blob-line-num{padding:10px 8px 9px;text-align:right;background:#fff;border:0}.markdown-body .csv-data tr{border-top:0}.markdown-body .csv-data th{font-weight:700;background:#f8f8f8;border-top:0}.markdown-body kbd{display:inline-block;padding:3px 5px;font-size:11px;line-height:10px;color:#555;vertical-align:middle;background-color:#fcfcfc;border:1px solid #ccc;border-bottom-color:#bbb;border-radius:3px;box-shadow:inset 0 -1px 0 #bbb}.news .alert .markdown-body blockquote{padding:0 0 0 40px;border:0 none}.activity-tab .news .alert .commits,.activity-tab .news .markdown-body blockquote{padding-left:0}.task-list-item{list-style-type:none}.task-list-item label{font-weight:400}.task-list-item.enabled label{cursor:pointer}.task-list-item+.task-list-item{margin-top:3px}.task-list-item-checkbox{float:left;margin:.31em 0 .2em -1.3em!important;vertical-align:middle;cursor:default!important}.markdown-body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,sans-serif;padding-top:40px;padding-bottom:40px;max-width:758px;overflow:visible!important}.markdown-body .emoji{vertical-align:top}.markdown-body pre{border:inherit!important}.markdown-body code{color:inherit!important}.markdown-body pre code .wrapper{display:-moz-inline-flex;display:-ms-inline-flex;display:-o-inline-flex;display:inline-flex}.markdown-body pre code .gutter{float:left;overflow:hidden;-webkit-user-select:none;user-select:none}.markdown-body pre code .gutter.linenumber{text-align:right;position:relative;display:inline-block;cursor:default;z-index:4;padding:0 8px 0 0;min-width:20px;box-sizing:content-box;color:#afafaf!important;border-right:3px solid #6ce26c!important}.markdown-body pre code .gutter.linenumber>span:before{content:attr(data-linenumber)}.markdown-body pre code .code{float:left;margin:0 0 0 16px}.markdown-body .gist .line-numbers{border-left:none;border-top:none;border-bottom:none}.markdown-body .gist .line-data{border:none}.markdown-body .gist table{border-spacing:0;border-collapse:inherit!important}.markdown-body code[data-gist-id]{background:none;padding:0}.markdown-body code[data-gist-id]:after,.markdown-body code[data-gist-id]:before{content:""}.markdown-body code[data-gist-id] .blob-num{border:unset}.markdown-body code[data-gist-id] table{overflow:unset;margin-bottom:unset}.markdown-body code[data-gist-id] table tr{background:unset}.markdown-body[dir=rtl] pre{direction:ltr}.markdown-body[dir=rtl] code{direction:ltr;unicode-bidi:embed}.markdown-body .alert>p{margin-bottom:0}.markdown-body pre.abc,.markdown-body pre.flow-chart,.markdown-body pre.graphviz,.markdown-body pre.mermaid,.markdown-body pre.sequence-diagram{text-align:center;background-color:inherit;border-radius:0;white-space:inherit}.markdown-body pre.abc>code,.markdown-body pre.flow-chart>code,.markdown-body pre.graphviz>code,.markdown-body pre.mermaid>code,.markdown-body pre.sequence-diagram>code{text-align:left}.markdown-body pre.abc>svg,.markdown-body pre.flow-chart>svg,.markdown-body pre.graphviz>svg,.markdown-body pre.mermaid>svg,.markdown-body pre.sequence-diagram>svg{max-width:100%;height:100%}.markdown-body pre>code.wrap{white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word}.markdown-body .alert>p,.markdown-body .alert>ul{margin-bottom:0}.markdown-body summary{display:list-item}.markdown-body summary:focus{outline:none}.markdown-body details summary{cursor:pointer}.markdown-body details:not([open])>:not(summary){display:none}.markdown-body figure{margin:1em 40px}.markdown-body .mark,.markdown-body mark{background-color:#fff1a7}.vimeo,.youtube{cursor:pointer;display:table;text-align:center;background-position:50%;background-repeat:no-repeat;background-size:contain;background-color:#000;overflow:hidden}.vimeo,.youtube{position:relative;width:100%}.youtube{padding-bottom:56.25%}.vimeo img{width:100%;object-fit:contain;z-index:0}.youtube img{object-fit:cover;z-index:0}.vimeo iframe,.youtube iframe,.youtube img{width:100%;height:100%;position:absolute;top:0;left:0}.vimeo iframe,.youtube iframe{vertical-align:middle;z-index:1}.vimeo .icon,.youtube .icon{position:absolute;height:auto;width:auto;top:50%;left:50%;transform:translate(-50%,-50%);color:#fff;opacity:.3;transition:opacity .2s;z-index:0}.vimeo:hover .icon,.youtube:hover .icon{opacity:.6;transition:opacity .2s}.slideshare .inner,.speakerdeck .inner{position:relative;width:100%}.slideshare .inner iframe,.speakerdeck .inner iframe{position:absolute;top:0;bottom:0;left:0;right:0;width:100%;height:100%}.MJX_Assistive_MathML{display:none}.ui-infobar{position:relative;z-index:2;max-width:760px;margin:25px auto -25px;padding:0 15px;color:#777}.toc .invisable-node{list-style-type:none}.ui-toc{position:fixed;bottom:20px;z-index:998}.ui-toc-label{opacity:.3;background-color:#ccc;border:none;transition:opacity .2s}.ui-toc .open .ui-toc-label{opacity:1;color:#fff;transition:opacity .2s}.ui-toc-label:focus{opacity:.3;background-color:#ccc;color:#000}.ui-toc-label:hover{opacity:1;background-color:#ccc;transition:opacity .2s}.ui-toc-dropdown{margin-top:23px;margin-bottom:20px;padding-left:10px;padding-right:10px;max-width:45vw;width:25vw;max-height:70vh;overflow:auto;text-align:inherit}.ui-toc-dropdown>.toc{max-height:calc(70vh - 100px);overflow:auto}.ui-toc-dropdown[dir=rtl] .nav{padding-right:0;letter-spacing:.0029em}.ui-toc-dropdown a{overflow:hidden;text-overflow:ellipsis;white-space:pre}.ui-toc-dropdown .nav>li>a{display:block;padding:4px 20px;font-size:13px;font-weight:500;color:#767676}.ui-toc-dropdown .nav>li:first-child:last-child > ul,.ui-toc-dropdown .toc.expand ul{display:block}.ui-toc-dropdown .nav>li>a:focus,.ui-toc-dropdown .nav>li>a:hover{padding-left:19px;color:#000;text-decoration:none;background-color:transparent;border-left:1px solid #000}.ui-toc-dropdown[dir=rtl] .nav>li>a:focus,.ui-toc-dropdown[dir=rtl] .nav>li>a:hover{padding-right:19px;border-left:none;border-right:1px solid #000}.ui-toc-dropdown .nav>.active:focus>a,.ui-toc-dropdown .nav>.active:hover>a,.ui-toc-dropdown .nav>.active>a{padding-left:18px;font-weight:700;color:#000;background-color:transparent;border-left:2px solid #000}.ui-toc-dropdown[dir=rtl] .nav>.active:focus>a,.ui-toc-dropdown[dir=rtl] .nav>.active:hover>a,.ui-toc-dropdown[dir=rtl] .nav>.active>a{padding-right:18px;border-left:none;border-right:2px solid #000}.ui-toc-dropdown .nav .nav{display:none;padding-bottom:10px}.ui-toc-dropdown .nav>.active>ul{display:block}.ui-toc-dropdown .nav .nav>li>a{padding-top:1px;padding-bottom:1px;padding-left:30px;font-size:12px;font-weight:400}.ui-toc-dropdown[dir=rtl] .nav .nav>li>a{padding-right:30px}.ui-toc-dropdown .nav .nav>li>ul>li>a{padding-top:1px;padding-bottom:1px;padding-left:40px;font-size:12px;font-weight:400}.ui-toc-dropdown[dir=rtl] .nav .nav>li>ul>li>a{padding-right:40px}.ui-toc-dropdown .nav .nav>li>a:focus,.ui-toc-dropdown .nav .nav>li>a:hover{padding-left:29px}.ui-toc-dropdown[dir=rtl] .nav .nav>li>a:focus,.ui-toc-dropdown[dir=rtl] .nav .nav>li>a:hover{padding-right:29px}.ui-toc-dropdown .nav .nav>li>ul>li>a:focus,.ui-toc-dropdown .nav .nav>li>ul>li>a:hover{padding-left:39px}.ui-toc-dropdown[dir=rtl] .nav .nav>li>ul>li>a:focus,.ui-toc-dropdown[dir=rtl] .nav .nav>li>ul>li>a:hover{padding-right:39px}.ui-toc-dropdown .nav .nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>a{padding-left:28px;font-weight:500}.ui-toc-dropdown[dir=rtl] .nav .nav>.active:focus>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active:hover>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active>a{padding-right:28px}.ui-toc-dropdown .nav .nav>.active>.nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active>a{padding-left:38px;font-weight:500}.ui-toc-dropdown[dir=rtl] .nav .nav>.active>.nav>.active:focus>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active>.nav>.active:hover>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active>.nav>.active>a{padding-right:38px}.markdown-body[lang^=ja]{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,Hiragino Kaku Gothic Pro,ヒラギノ角ゴ Pro W3,Osaka,Meiryo,メイリオ,MS Gothic,ＭＳ\ ゴシック,sans-serif}.ui-toc-dropdown[lang^=ja]{font-family:Source Sans Pro,Helvetica,Arial,Meiryo UI,MS PGothic,ＭＳ\ Ｐゴシック,sans-serif}.markdown-body[lang=zh-tw]{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,PingFang TC,Microsoft JhengHei,微軟正黑,sans-serif}.ui-toc-dropdown[lang=zh-tw]{font-family:Source Sans Pro,Helvetica,Arial,Microsoft JhengHei UI,微軟正黑UI,sans-serif}.markdown-body[lang=zh-cn]{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,PingFang SC,Microsoft YaHei,微软雅黑,sans-serif}.ui-toc-dropdown[lang=zh-cn]{font-family:Source Sans Pro,Helvetica,Arial,Microsoft YaHei UI,微软雅黑UI,sans-serif}.ui-affix-toc{position:fixed;top:0;max-width:15vw;max-height:70vh;overflow:auto}.back-to-top,.expand-toggle,.go-to-bottom{display:block;padding:4px 10px;margin-top:10px;margin-left:10px;font-size:12px;font-weight:500;color:#999}.back-to-top:focus,.back-to-top:hover,.expand-toggle:focus,.expand-toggle:hover,.go-to-bottom:focus,.go-to-bottom:hover{color:#563d7c;text-decoration:none}.back-to-top,.go-to-bottom{margin-top:0}.ui-user-icon{width:20px;height:20px;display:block;border-radius:3px;margin-top:2px;margin-bottom:2px;margin-right:5px;background-position:50%;background-repeat:no-repeat;background-size:cover}.ui-user-icon.small{width:18px;height:18px;display:inline-block;vertical-align:middle;margin:0 0 .2em}.ui-infobar>small>span{line-height:22px}.ui-infobar>small .dropdown{display:inline-block}.ui-infobar>small .dropdown a:focus,.ui-infobar>small .dropdown a:hover{text-decoration:none}.ui-published-note{color:#337ab7}.ui-published-note .fa{font-size:20px;vertical-align:top}.unselectable{-webkit-user-select:none;-o-user-select:none;user-select:none}@media print{blockquote,div,img,pre,table{page-break-inside:avoid!important}a[href]:after{font-size:12px!important}}.markdown-body.slides{position:relative;z-index:1;color:#222}.markdown-body.slides:before{content:"";display:block;position:absolute;top:0;left:0;right:0;bottom:0;z-index:-1;background-color:currentColor;box-shadow:0 0 0 50vw}.markdown-body.slides section[data-markdown]{position:relative;margin-bottom:1.5em;background-color:#fff;text-align:center}.markdown-body.slides section[data-markdown] code{text-align:left}.markdown-body.slides section[data-markdown]:before{content:"";display:block;padding-bottom:56.23%}.markdown-body.slides section[data-markdown]>div:first-child{position:absolute;top:50%;left:1em;right:1em;transform:translateY(-50%);max-height:100%;overflow:hidden}.markdown-body.slides section[data-markdown]>ul{display:inline-block}.markdown-body.slides>section>section+section:after{content:"";position:absolute;top:-1.5em;right:1em;height:1.5em;border:3px solid #777}body{font-smoothing:subpixel-antialiased!important;-webkit-font-smoothing:subpixel-antialiased!important;-moz-osx-font-smoothing:auto!important;text-shadow:0 0 1em transparent,1px 1px 1.2px rgba(0,0,0,.004);-webkit-overflow-scrolling:touch;font-family:Source Sans Pro,Helvetica,Arial,sans-serif;letter-spacing:.025em}.focus,:focus{outline:none!important}::-moz-focus-inner{border:0!important}body.modal-open{overflow-y:auto;padding-right:0!important}
    </style>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js" integrity="sha256-3Jy/GbSLrg0o9y5Z5n1uw0qxZECH7C6OQpVBgNFYa0g=" crossorigin="anonymous"></script>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js" integrity="sha256-g6iAfvZp+nDQ2TdTR/VVKJf3bGro4ub5fvWSWVRi2NE=" crossorigin="anonymous"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.9/es5-shim.min.js" integrity="sha256-8E4Is26QH0bD52WoQpcB+R/tcWQtpzlCojrybUd7Mxo=" crossorigin="anonymous"></script>
    <![endif]-->
</head>

<body>
    <div id="doc" class="markdown-body container-fluid comment-enabled"><style>
ins { background-color: #A0FFA0 }
s { background-color: #FFA0A0 }
blockquote { color: inherit !important }
</style><table><tbody>
<tr><th>Doc. no.:</th>    <td>P1652R1</td></tr>
<tr><th>Date:</th>    <td>2019-07-17</td></tr>
<tr><th>Audience:</th>    <td>LWG</td></tr>
<tr><th>Reply-to:</th>    <td>Zhihao Yuan &lt;zy@miator.net&gt;<br>
                              Victor Zverovich &lt;victor.zverovich@gmail.com&gt;</td></tr>
</tbody></table><h1 id="Printf-corner-cases-in-stdformat"><a class="anchor hidden-xs" href="#Printf-corner-cases-in-stdformat" title="Printf-corner-cases-in-stdformat"><span class="octicon octicon-link"></span></a>Printf corner cases in <code>std::format</code></h1><h2 id="Changes-since-R0"><a class="anchor hidden-xs" href="#Changes-since-R0" title="Changes-since-R0"><span class="octicon octicon-link"></span></a>Changes since R0</h2><ul>
<li>rebase the wording on top of P0645R10</li>
<li>replace “applying” with “applied”</li>
<li>replace “the ‘0’” with “the ‘0’ character”</li>
<li>add an example demonstrating that the ‘0’ character is ignored when used together with alignment</li>
<li>replace “. In such a case” with “, in which case”</li>
</ul><h2 id="Introduction"><a class="anchor hidden-xs" href="#Introduction" title="Introduction"><span class="octicon octicon-link"></span></a>Introduction</h2><p>Printf heavily influences the formatting behavior design of <code>std::format</code> and Python <code>str.format</code>.  However, in the process of development, the current specification of <code>std::format</code><sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup> misses a few beneficial outcomes comparing to <code>printf</code> and Python but inherits some unnecessary compromise from iostreams.  This document is to show these corner cases and propose solutions in C++20.</p><h2 id="Problem-1-‘o’-specification-should-not-print-0-as-“00”"><a class="anchor hidden-xs" href="#Problem-1-‘o’-specification-should-not-print-0-as-“00”" title="Problem-1-‘o’-specification-should-not-print-0-as-“00”"><span class="octicon octicon-link"></span></a>Problem 1: ‘#o’ specification should not print 0 as “00”</h2><table>
<thead>
<tr>
<th>variant</th>
<th>behavior</th>
</tr>
</thead>
<tbody>
<tr>
<td>printf</td>
<td>#o and #x print “0” for 0</td>
</tr>
<tr>
<td>Python</td>
<td>#o, #x, and #b print “0o0”, “0x0”, “0b0”, respectively, for 0</td>
</tr>
<tr>
<td>format</td>
<td>#o, #x, and #b print “00”, “0x0”, “0b0”, respectively, for 0</td>
</tr>
</tbody>
</table><p>0o<em>dddd</em> is not a pattern for octal literals in C++, so <code>std::format</code> replaces it with printf’s pattern <em>dddd</em> for #o.  However, the <code>#</code> flag in printf is specified as follows<sup class="footnote-ref"><a href="#fn2" id="fnref2">[2]</a></sup>:</p><blockquote>
<p>For <code>o</code> conversion, it increases the precision, if and only if necessary, to force the first digit of the result to be a zero (if the value and precision are both 0, a single 0 is printed).</p>
</blockquote><p>The output here matches C++ syntax where 0 is an octal literal.  We propose to respecify <code>std::format</code> ‘#o’ to match printf output.</p><p><strong>Before</strong>:</p><pre><code class="c++ hljs"><span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{:#o}"</span>, <span class="hljs-number">0</span>); <span class="hljs-comment">// s == "00"</span>
</code></pre><p><strong>After</strong>:</p><pre><code class="c++ hljs"><span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{:#o}"</span>, <span class="hljs-number">0</span>); <span class="hljs-comment">// s == "0"</span>
</code></pre><h2 id="Problem-2-‘c’-should-be-able-to-print-65-as-“A”-ASCII"><a class="anchor hidden-xs" href="#Problem-2-‘c’-should-be-able-to-print-65-as-“A”-ASCII" title="Problem-2-‘c’-should-be-able-to-print-65-as-“A”-ASCII"><span class="octicon octicon-link"></span></a>Problem 2: ‘c’ should be able to print 65 as “A” (ASCII)</h2><table>
<thead>
<tr>
<th>variant</th>
<th>behavior</th>
</tr>
</thead>
<tbody>
<tr>
<td>printf</td>
<td>‘c’ prints “A” for 65, ‘lc’ prints “A” for <code>(wint_t)</code>65</td>
</tr>
<tr>
<td>Python</td>
<td>‘c’ prints “A” for 65</td>
</tr>
<tr>
<td>format</td>
<td>throws an exception</td>
</tr>
</tbody>
</table><p>Not allowing ‘c’ to print integer generates a usability problem – the users won’t be able to print the return value of invoking <code>cin.get()</code> (also <code>getc</code> and <code>fgetc</code>) as characters.  It is hostile to C++ learners if a cast is required to use stdio or iostreams with <code>std::format</code> for such a trivial task, while “{:c}” can be a way for them to express “show me a character
here.”</p><p>We propose to let integer presentation types support a new flag, ‘c’, which prints the argument <code>x</code> as-if <code>static_cast&lt;charT&gt;(x)</code>, where <code>charT</code> is the character type of the format string defined in P0645. If the argument is not in the range representable by <code>charT</code>, <code>format_error</code> is thrown.</p><p><strong>Before</strong>:</p><pre><code class="c++ hljs"><span class="hljs-keyword">int</span> c = <span class="hljs-string">'A'</span>;
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{:c}"</span>, c); <span class="hljs-comment">// throws format_error</span>
</code></pre><p><strong>After</strong>:</p><pre><code class="c++ hljs"><span class="hljs-keyword">int</span> c = <span class="hljs-string">'A'</span>;
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{:c}"</span>, c); <span class="hljs-comment">// s == "A"</span>
</code></pre><h2 id="Problem-3-“-000nan”-is-not-a-floating-point-value"><a class="anchor hidden-xs" href="#Problem-3-“-000nan”-is-not-a-floating-point-value" title="Problem-3-“-000nan”-is-not-a-floating-point-value"><span class="octicon octicon-link"></span></a>Problem 3: “-000nan” is not a floating point value</h2><p>What <code>printf("%07", -nan(""))</code> prints is underspecified until C99<sup class="footnote-ref"><a href="#fn2" id="fnref2:1">[2:1]</a></sup> and POSIX 2008<sup class="footnote-ref"><a href="#fn3" id="fnref3">[3]</a></sup>, where the effect of ‘0’ flag is described as:</p><blockquote>
<p>For <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, <strong>X</strong>, <strong>a</strong>, <strong>A</strong>, <strong>e</strong>, <strong>E</strong>, <strong>f</strong>, <strong>F</strong>, <strong>g</strong>, and <strong>G</strong> conversions, leading zeros (following any indication of sign or base) are used to pad to the field width rather than performing space padding, except when converting an infinity or NaN. […]</p>
</blockquote><p>The last clause did not present in C89, C90, and POSIX 2003.  The output “-000nan” cannot be correctly parsed by iostreams and <code>strtod</code>.  As of 2016, FreeBSD libc, glibc, and Microsoft UCRT have all avoided it.</p><p>However, iostreams mandates this pathological output with the <code>internal</code> iomanip.  This output also presents in Python and fmt where the <code>=</code> <em>alignment</em> type is functionally equivalent to <code>internal</code>.  Even worse, the dedicated ‘0’ <em>std-format-spec</em> is specified as  “[…] equivalent to a fill character of ‘0’ with an <em>alignment</em> type of ‘=’”.  So the output of ‘0’ flag in Python and fmt is incompatible with printf ‘0’ flag.</p><p>The observations are:</p><ol>
<li>The <code>internal</code> iomanip only affects numeric output and does it poorly;</li>
<li>The ‘=’ <em>alignment</em> type inherited all issues from <code>internal</code> and is verbose to write, hard to interpret, compared to ‘0’.</li>
</ol><p>Therefore, we propose to remove the ‘=’ <em>alignment</em> type and respecify ‘0’ to match C99 printf’s output.  Note that Rust <code>std::fmt</code>, a newer Python-like formatting facility, also removed the ‘=’ align spec.<sup class="footnote-ref"><a href="#fn4" id="fnref4">[4]</a></sup></p><p><strong>Before</strong>:</p><pre><code class="c++ hljs"><span class="hljs-keyword">double</span> nan = <span class="hljs-built_in">std</span>::numeric_limits&lt;<span class="hljs-keyword">double</span>&gt;::quiet_NaN();
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s1 = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{:0=6}"</span>, nan); <span class="hljs-comment">// s1 == "000nan"</span>
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s2 = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{:06}"</span>, nan);  <span class="hljs-comment">// s2 == "000nan"</span>
</code></pre><p><strong>After</strong>:</p><pre><code class="c++ hljs"><span class="hljs-keyword">double</span> nan = <span class="hljs-built_in">std</span>::numeric_limits&lt;<span class="hljs-keyword">double</span>&gt;::quiet_NaN();
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s1 = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{:0=6}"</span>, nan); <span class="hljs-comment">// throws format_error</span>
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s2 = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{:06}"</span>, nan);  <span class="hljs-comment">// s2 == "   nan"</span>
</code></pre><h2 id="Problem-4-bool-needs-a-type-format-specifier"><a class="anchor hidden-xs" href="#Problem-4-bool-needs-a-type-format-specifier" title="Problem-4-bool-needs-a-type-format-specifier"><span class="octicon octicon-link"></span></a>Problem 4: bool needs a type format specifier</h2><table>
<thead>
<tr>
<th>variant</th>
<th>behavior</th>
</tr>
</thead>
<tbody>
<tr>
<td>printf</td>
<td>does not print <code>bool</code> as “true” or “false”</td>
</tr>
<tr>
<td>iostreams</td>
<td>via <code>boolalpha</code> iomanip</td>
</tr>
<tr>
<td>Python</td>
<td>no type format specifier for <code>bool</code> but empty format specification invokes <code>str()</code><sup class="footnote-ref"><a href="#fn5" id="fnref5">[5]</a></sup> which returns “True” or “False”</td>
</tr>
<tr>
<td>format</td>
<td>no type format specifier for <code>bool</code> but empty format specification gives “true” or “false”</td>
</tr>
</tbody>
</table><p>So <code>std::format</code> can only print <code>bool</code> <em>without</em> a type format specifier, distinguishing it from all other fundamental types and string-like types.  We consider ‘s’ flag to be a “Do What I Mean” (DWIM) improvement to this caveat.  Note that the fmt library supports printing <code>bool</code> via <code>%s</code> in printf-compatible syntax<sup class="footnote-ref"><a href="#fn6" id="fnref6">[6]</a></sup>, but did not propose the syntax for standardization.</p><p><strong>Before</strong>:</p><pre><code class="c++ hljs"><span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{:s}"</span>, <span class="hljs-literal">true</span>); <span class="hljs-comment">// throws format_error</span>
</code></pre><p><strong>After</strong>:</p><pre><code class="c++ hljs"><span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{:s}"</span>, <span class="hljs-literal">true</span>); <span class="hljs-comment">// s == "true"</span>
</code></pre><h2 id="Problem-5-double-does-not-roundtrip-float"><a class="anchor hidden-xs" href="#Problem-5-double-does-not-roundtrip-float" title="Problem-5-double-does-not-roundtrip-float"><span class="octicon octicon-link"></span></a>Problem 5: <code>double</code> does not roundtrip <code>float</code></h2><table>
<thead>
<tr>
<th>variant</th>
<th>roundtrip <code>double</code> in <br>shortest decimal representation</th>
<th><code>float</code> behavior</th>
</tr>
</thead>
<tbody>
<tr>
<td>printf</td>
<td>No</td>
<td><code>float</code> is promoted to <code>double</code></td>
</tr>
<tr>
<td>iostreams</td>
<td>No</td>
<td><code>float</code> is converted to <code>double</code></td>
</tr>
<tr>
<td>Python</td>
<td>Yes</td>
<td>does not support float32</td>
</tr>
<tr>
<td>format</td>
<td>Yes</td>
<td><code>float</code> is converted to <code>double</code></td>
</tr>
</tbody>
</table><p>Python prints shortest round-trip representations for floating point values by default; so does <code>std::format</code> – but not for <code>float</code>.  Single-precision floating point values roundtrip in their realm and are already supported by <code>std::to_chars</code>.  We should print a <code>float</code> as <code>float</code> rather than a long string used for disambiguating the value in <code>double</code>'s realm.</p><p><strong>Before</strong>:</p><pre><code class="c++ hljs"><span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{}"</span>, <span class="hljs-number">3.31f</span>); <span class="hljs-comment">// s == "3.309999942779541"</span>
</code></pre><p><strong>After</strong>:</p><pre><code class="c++ hljs"><span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span> s = <span class="hljs-built_in">std</span>::format(<span class="hljs-string">"{}"</span>, <span class="hljs-number">3.31f</span>); <span class="hljs-comment">// s == "3.31"</span>
</code></pre><h2 id="Wording"><a class="anchor hidden-xs" href="#Wording" title="Wording"><span class="octicon octicon-link"></span></a>Wording</h2><p>The wording is relative to P0645R10.</p><p>Modify 19.?.2 [format.string] as follows:</p><pre><code>format-spec     ::= std-format-spec | custom-format-spec
std-format-spec ::= [[fill] align] [sign] ['#'] ['0'] [width] ['.' precision] [type]
fill            ::= &lt;a character other than '{' or '}'&gt;
align           ::= '&lt;' | '&gt;' | <s>'=' | </s>'^'
sign            ::= '+' | '-' | ' '
width           ::= nonzero-digit [integer] | '{' arg-id '}'
precision       ::= integer | '{' arg-id '}'
type            ::= 'a' | 'A' | 'b' | 'B' | 'c' | 'd' | 'e' | 'E' | 'f' | 'F' |
                    'g' | 'G' | 'n' | 'o' | 'p' | 's' | 'x' | 'X'
</code></pre><p>[…]</p><p>The meaning of the various alignment options is as follows:</p><table>
<thead>
<tr>
<th>Option</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>'&lt;'</code></td>
<td>Forces the field to be left-aligned within the available space. This is the default for non-arithmetic types, <code>charT</code>, and <code>bool</code>, unless an integer presentation type is specified.</td>
</tr>
<tr>
<td><code>'&gt;'</code></td>
<td>Forces the field to be right-aligned within the available space. This is the default for arithmetic types other than <code>charT</code> and <code>bool</code> or when an integer presentation type is specified.</td>
</tr>
<tr>
<td><s><code>'='</code></s></td>
<td><s>Forces the padding to be placed after the sign or prefix (if any) but before the digits. This is used for printing fields in the form <code>+000000120</code>. This alignment option is only valid for arithmetic types other than <code>charT</code> and <code>bool</code> or when an integer presentation type is specified.</s></td>
</tr>
<tr>
<td><code>'^'</code></td>
<td>Forces the field to be centered within the available space by inserting <em>N</em><code>/ 2</code> and <em>N</em><code>-</code><em>N</em><code>/ 2</code> fill characters before and after the value respectively, where <em>N</em> is the total number of fill characters to insert.</td>
</tr>
</tbody>
</table><p>[<em>Example:</em></p><pre><code>char c = 120;
string s0 = format("{:6}", 42);      // s0 == "    42"
string s1 = format("{:6}", 'x');     // s1 == "x     "
string s2 = format("{:*&lt;6}", 'x');   // s2 == "x*****"
string s3 = format("{:*&gt;6}", 'x');   // s3 == "*****x"
string s4 = format("{:*^6}", 'x');   // s4 == "**x***"
<s>string s5 = format("{:=6}", 'x');    // Error: '=' with charT and no integer presentation type</s>
string s<s>6</s><ins>5</ins> = format("{:6d}", c);      // s<s>6</s><ins>5</ins> == "   120"
<s>string s7 = format("{:=+06d}", c);   // s7 == "+00120"
string s8 = format("{:0=#6x}", 0xa); // s8 == "0x000a"</s>
string s<s>9</s><ins>6</ins> = format("{:6}", true);    // s<s>9</s><ins>6</ins> == "true  "
</code></pre><p><em>–end example</em>]</p><p>The <code>'#'</code> option causes the alternate form to be used for the conversion. This option is only valid for arithmetic types other than <code>charT</code> and <code>bool</code> or when an integer presentation type is specified. For integers, when binary <s>, octal,</s> or hexadecimal output is used, this option adds the respective prefix <code>"0b"</code> (<code>"0B"</code>) <s>, <code>"0"</code>,</s> or <code>"0x"</code> (<code>"0X"</code>) to the output value. Whether the prefix is lower-case or upper-case is determined by the case of the type format specifier. <ins>The option prefixes the output value with <code>"0"</code> when octal output is used on nonzero integers.</ins> For floating-point numbers […]</p><p><em>width</em> is a decimal integer defining the minimum field width. If not specified, then the field width will be determined by the content.</p><p>Preceding the <em>width</em> field by a zero (<code>'0'</code>) character <s>enables sign-aware zero-padding for arithmetic types. This is equivalent to a <em>fill</em> character of <code>'0'</code> with an <em>alignment</em> type of <code>'='</code>.</s> <ins>pads leading zeros (following any indication of sign or base) to the field width, except when applied to an infinity or NaN. This option is only valid for arithmetic types other than <code>charT</code> and <code>bool</code> or when an integer presentation type is specified. If the ‘0’ character and an <em>align</em> option both appear, the ‘0’ character is ignored. [<em>Example:</em></ins></p><pre><code><ins>char c = 120;
string s1 = format("{:+06d}", c);    // s1 == "+00120"
string s2 = format("{:#06x}", 0xa);  // s2 == "0x000a"
string s3 = format("{:&lt;06}", -42);   // s3 == "-42   " ('0' is ignored because of the '&lt;' alignment)
</ins>
</code></pre><p><ins><em>–end example</em>]</ins></p><p>[…]</p><p>The available integer presentation types and their mapping to <code>to_chars</code> are:</p><table>
<thead>
<tr>
<th>Option</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>'b'</code></td>
<td><code>to_chars(first, last, value, 2)</code>; using the <code>'#'</code> option with this type adds the prefix <code>"0b"</code> to the output.</td>
</tr>
<tr>
<td><code>'B'</code></td>
<td>The same as <code>'b'</code>, except that the <code>'#'</code> option adds the prefix <code>"0B"</code> to the output.</td>
</tr>
<tr>
<td><ins><code>'c'</code></ins></td>
<td><ins>Copies the character<code>static_cast&lt;charT&gt;(value)</code> to the output. Throws <code>format_error</code> if <code>value</code> is not in the range of representable values for <code>charT</code>.</ins></td>
</tr>
<tr>
<td><code>'d'</code></td>
<td><code>to_chars(first, last, value)</code>.</td>
</tr>
<tr>
<td>[…]</td>
<td>[…]</td>
</tr>
<tr>
<td>none</td>
<td>The same as <code>'d'</code> if the formatting argument type is not <code>charT</code> or <code>bool</code>.</td>
</tr>
</tbody>
</table><p>Integer presentation types can also be used with <code>charT</code> and <code>bool</code> values <s>.</s> <ins>, in which case a <code>value</code> of type <code>bool</code> is treated as <code>static_cast&lt;unsigned char&gt;(value)</code>.</ins> <s>Values of type <code>bool</code> are formatted using textual representation, either <code>"true"</code> or <code>"false"</code>, if the presentation type is not specified.</s> [<em>Example:</em> … <em>–end example</em>]</p><div class="alert alert-warning">
<p>[<em>Drafting note:</em>
A drive-by fix – <code>to_chars</code> has no overload for <code>bool</code>.
<em>–end note</em>]</p>
</div><p>For lower-case presentation types, infinity and NaN are formatted as <code>"inf"</code> and <code>"nan"</code>, respectively, with sign, if any. For upper-case presentation types, infinity and NaN are formatted as <code>"INF"</code> and <code>"NAN"</code>, respectively, with sign, if any.</p><p><ins>The available <code>bool</code> presentation types are:</ins></p><table>
<thead>
<tr>
<th><ins>Type</ins></th>
<th><ins>Meaning</ins></th>
</tr>
</thead>
<tbody>
<tr>
<td><ins><code>'s'</code></ins></td>
<td><ins>Copies textual representation, either “true” or “false”, to the output.</ins></td>
</tr>
<tr>
<td><ins>none</ins></td>
<td><ins>The same as ‘s’.</ins></td>
</tr>
</tbody>
</table><p>The available pointer presentation types and their mapping to <code>to_chars</code> are:</p><p>[…]</p><p>Modify 19.?.4.1 [format.arg] as follows:</p><pre><code>namespace std {
  template&lt;class Context&gt;
  class basic_format_arg {
  public:
    class handle;

    using char_type = typename Context::char_type;                     // exposition only

    variant&lt;monostate, bool, char_type,
            int, unsigned int, long long int, unsigned long long int,
            <ins>float, </ins>double, long double,
            const char_type*, basic_string_view&lt;char_type&gt;,
            const void*, handle&gt; value;                                // exposition only

    basic_format_arg() noexcept;
</code></pre><p>[…]</p><pre><code>explicit basic_format_arg(float n) noexcept;
</code></pre><blockquote>
<p><s><em>Effects:</em> Initializes <code>value</code> with <code>static_cast&lt;double&gt;(n)</code>.</s></p>
</blockquote><pre><code>explicit basic_format_arg(double n) noexcept;
explicit basic_format_arg(long double n) noexcept;
</code></pre><blockquote>
<p><em>Effects:</em> Initializes <code>value</code> with <code>n</code>.</p>
</blockquote><h2 id="References"><a class="anchor hidden-xs" href="#References" title="References"><span class="octicon octicon-link"></span></a>References</h2><hr class="footnotes-sep"><section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"><p>Text Formatting.
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html" target="_blank" rel="noopener">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html</a> <a href="#fnref1" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn2" class="footnote-item"><p>ISO/IEC 9899:TC3 Committee Draft.
<a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf" target="_blank" rel="noopener">http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf</a> <a href="#fnref2" class="footnote-backref">↩︎</a> <a href="#fnref2:1" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn3" class="footnote-item"><p>dprintf, fprintf, printf, snprintf, sprintf - print formatted output, The Open Group Base Specifications Issue 7, 2018 edition.
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html" target="_blank" rel="noopener">http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html</a> <a href="#fnref3" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn4" class="footnote-item"><p>Syntax, Module <code>std::fmt</code>.
<a href="https://doc.rust-lang.org/std/fmt/#syntax" target="_blank" rel="noopener">https://doc.rust-lang.org/std/fmt/#syntax</a> <a href="#fnref4" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn5" class="footnote-item"><p>Printing boolean values True/False with the format() method in Python.
<a href="https://stackoverflow.com/questions/23655005/printing-boolean-values-true-false-with-the-format-method-in-python/23666923" target="_blank" rel="noopener">https://stackoverflow.com/questions/23655005/printing-boolean-values-true-false-with-the-format-method-in-python/23666923</a> <a href="#fnref5" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn6" class="footnote-item"><p>Formatting bool with ‘s’ type specifier should give textual output.
<a href="https://github.com/fmtlib/fmt/issues/224" target="_blank" rel="noopener">https://github.com/fmtlib/fmt/issues/224</a> <a href="#fnref6" class="footnote-backref">↩︎</a></p>
</li>
</ol>
</section></div>
    <div class="ui-toc dropup unselectable hidden-print" style="display:none;">
        <div class="pull-right dropdown">
            <a id="tocLabel" class="ui-toc-label btn btn-default" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false" title="Table of content">
                <i class="fa fa-bars"></i>
            </a>
            <ul id="ui-toc" class="ui-toc-dropdown dropdown-menu" aria-labelledby="tocLabel">
                <div class="toc"><ul class="nav">
<li class=""><a href="#Printf-corner-cases-in-stdformat" title="Printf corner cases in std::format">Printf corner cases in std::format</a><ul class="nav">
<li><a href="#Changes-since-R0" title="Changes since R0">Changes since R0</a></li>
<li><a href="#Introduction" title="Introduction">Introduction</a></li>
<li><a href="#Problem-1-‘o’-specification-should-not-print-0-as-“00”" title="Problem 1: ‘#o’ specification should not print 0 as “00”">Problem 1: ‘#o’ specification should not print 0 as “00”</a></li>
<li><a href="#Problem-2-‘c’-should-be-able-to-print-65-as-“A”-ASCII" title="Problem 2: ‘c’ should be able to print 65 as “A” (ASCII)">Problem 2: ‘c’ should be able to print 65 as “A” (ASCII)</a></li>
<li><a href="#Problem-3-“-000nan”-is-not-a-floating-point-value" title="Problem 3: “-000nan” is not a floating point value">Problem 3: “-000nan” is not a floating point value</a></li>
<li><a href="#Problem-4-bool-needs-a-type-format-specifier" title="Problem 4: bool needs a type format specifier">Problem 4: bool needs a type format specifier</a></li>
<li><a href="#Problem-5-double-does-not-roundtrip-float" title="Problem 5: double does not roundtrip float">Problem 5: double does not roundtrip float</a></li>
<li><a href="#Wording" title="Wording">Wording</a></li>
<li><a href="#References" title="References">References</a></li>
</ul>
</li>
</ul>
</div><div class="toc-menu"><a class="expand-toggle" href="#">Expand all</a><a class="back-to-top" href="#">Back to top</a><a class="go-to-bottom" href="#">Go to bottom</a></div>
            </ul>
        </div>
    </div>
    <div id="ui-toc-affix" class="ui-affix-toc ui-toc-dropdown unselectable hidden-print" data-spy="affix" style="top:17px;display:none;"  >
        <div class="toc"><ul class="nav">
<li class=""><a href="#Printf-corner-cases-in-stdformat" title="Printf corner cases in std::format">Printf corner cases in std::format</a><ul class="nav">
<li><a href="#Changes-since-R0" title="Changes since R0">Changes since R0</a></li>
<li><a href="#Introduction" title="Introduction">Introduction</a></li>
<li><a href="#Problem-1-‘o’-specification-should-not-print-0-as-“00”" title="Problem 1: ‘#o’ specification should not print 0 as “00”">Problem 1: ‘#o’ specification should not print 0 as “00”</a></li>
<li><a href="#Problem-2-‘c’-should-be-able-to-print-65-as-“A”-ASCII" title="Problem 2: ‘c’ should be able to print 65 as “A” (ASCII)">Problem 2: ‘c’ should be able to print 65 as “A” (ASCII)</a></li>
<li><a href="#Problem-3-“-000nan”-is-not-a-floating-point-value" title="Problem 3: “-000nan” is not a floating point value">Problem 3: “-000nan” is not a floating point value</a></li>
<li><a href="#Problem-4-bool-needs-a-type-format-specifier" title="Problem 4: bool needs a type format specifier">Problem 4: bool needs a type format specifier</a></li>
<li><a href="#Problem-5-double-does-not-roundtrip-float" title="Problem 5: double does not roundtrip float">Problem 5: double does not roundtrip float</a></li>
<li><a href="#Wording" title="Wording">Wording</a></li>
<li><a href="#References" title="References">References</a></li>
</ul>
</li>
</ul>
</div><div class="toc-menu"><a class="expand-toggle" href="#">Expand all</a><a class="back-to-top" href="#">Back to top</a><a class="go-to-bottom" href="#">Go to bottom</a></div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous" defer></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.6.0/gist-embed.min.js" integrity="sha256-KyF2D6xPIJUW5sUDSs93vWyZm+1RzIpKCexxElmxl8g=" crossorigin="anonymous" defer></script>
    <script>
        var markdown = $(".markdown-body");
        //smooth all hash trigger scrolling
        function smoothHashScroll() {
            var hashElements = $("a[href^='#']").toArray();
            for (var i = 0; i < hashElements.length; i++) {
                var element = hashElements[i];
                var $element = $(element);
                var hash = element.hash;
                if (hash) {
                    $element.on('click', function (e) {
                        // store hash
                        var hash = this.hash;
                        if ($(hash).length <= 0) return;
                        // prevent default anchor click behavior
                        e.preventDefault();
                        // animate
                        $('body, html').stop(true, true).animate({
                            scrollTop: $(hash).offset().top
                        }, 100, "linear", function () {
                            // when done, add hash to url
                            // (default click behaviour)
                            window.location.hash = hash;
                        });
                    });
                }
            }
        }

        smoothHashScroll();
        var toc = $('.ui-toc');
        var tocAffix = $('.ui-affix-toc');
        var tocDropdown = $('.ui-toc-dropdown');
        //toc
        tocDropdown.click(function (e) {
            e.stopPropagation();
        });

        var enoughForAffixToc = true;

        function generateScrollspy() {
            $(document.body).scrollspy({
                target: ''
            });
            $(document.body).scrollspy('refresh');
            if (enoughForAffixToc) {
                toc.hide();
                tocAffix.show();
            } else {
                tocAffix.hide();
                toc.show();
            }
            $(document.body).scroll();
        }

        function windowResize() {
            //toc right
            var paddingRight = parseFloat(markdown.css('padding-right'));
            var right = ($(window).width() - (markdown.offset().left + markdown.outerWidth() - paddingRight));
            toc.css('right', right + 'px');
            //affix toc left
            var newbool;
            var rightMargin = (markdown.parent().outerWidth() - markdown.outerWidth()) / 2;
            //for ipad or wider device
            if (rightMargin >= 133) {
                newbool = true;
                var affixLeftMargin = (tocAffix.outerWidth() - tocAffix.width()) / 2;
                var left = markdown.offset().left + markdown.outerWidth() - affixLeftMargin;
                tocAffix.css('left', left + 'px');
            } else {
                newbool = false;
            }
            if (newbool != enoughForAffixToc) {
                enoughForAffixToc = newbool;
                generateScrollspy();
            }
        }
        $(window).resize(function () {
            windowResize();
        });
        $(document).ready(function () {
            windowResize();
            generateScrollspy();
        });

        //remove hash
        function removeHash() {
            window.location.hash = '';
        }

        var backtotop = $('.back-to-top');
        var gotobottom = $('.go-to-bottom');

        backtotop.click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            if (scrollToTop)
                scrollToTop();
            removeHash();
        });
        gotobottom.click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            if (scrollToBottom)
                scrollToBottom();
            removeHash();
        });

        var toggle = $('.expand-toggle');
        var tocExpand = false;

        checkExpandToggle();
        toggle.click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            tocExpand = !tocExpand;
            checkExpandToggle();
        })

        function checkExpandToggle () {
            var toc = $('.ui-toc-dropdown .toc');
            var toggle = $('.expand-toggle');
            if (!tocExpand) {
                toc.removeClass('expand');
                toggle.text('Expand all');
            } else {
                toc.addClass('expand');
                toggle.text('Collapse all');
            }
        }

        function scrollToTop() {
            $('body, html').stop(true, true).animate({
                scrollTop: 0
            }, 100, "linear");
        }

        function scrollToBottom() {
            $('body, html').stop(true, true).animate({
                scrollTop: $(document.body)[0].scrollHeight
            }, 100, "linear");
        }
    </script>
</body>

</html>
