Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use the non-standard <code>apostrophe</code> flag in the printf format string, if you have that option available and don't mind losing a little bit of portability.</p> <p>According to my documentation, the <code>'</code> flag is available for <a href="http://en.wikipedia.org/wiki/Posix" rel="noreferrer" title="Portable Operating System Interface [for Unix]">POSIX</a> systems since 1997.</p> <p>If you are on Unix, Linux, Mac, ... you should have no problem<br> If you are on Windows, DOS, iSeries, Android, ... all bets are off (but maybe you can install a POSIX layer to your system).</p> <pre><code>#include &lt;locale.h&gt; #include &lt;stdio.h&gt; int main(void) { long int x = 130006714000000; setlocale(LC_NUMERIC, "en_US.utf-8"); /* important */ while (x &gt; 0) { printf("# %%'22ld: %'22ld\n", x); /* apostrophe flag */ x *= 2; /* on my machine, the Undefined Behaviour for overflow // makes the number become negative with no ill effects */ } return 0; } </code></pre> <p>On my system this program produces:</p> <pre><code># %'22ld: 130,006,714,000,000 # %'22ld: 260,013,428,000,000 # %'22ld: 520,026,856,000,000 # %'22ld: 1,040,053,712,000,000 # %'22ld: 2,080,107,424,000,000 # %'22ld: 4,160,214,848,000,000 # %'22ld: 8,320,429,696,000,000 # %'22ld: 16,640,859,392,000,000 # %'22ld: 33,281,718,784,000,000 # %'22ld: 66,563,437,568,000,000 # %'22ld: 133,126,875,136,000,000 # %'22ld: 266,253,750,272,000,000 # %'22ld: 532,507,500,544,000,000 # %'22ld: 1,065,015,001,088,000,000 # %'22ld: 2,130,030,002,176,000,000 # %'22ld: 4,260,060,004,352,000,000 # %'22ld: 8,520,120,008,704,000,000 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload