How to group decimal places as well? The 2019 Stack Overflow Developer Survey Results Are In ...

Am I ethically obligated to go into work on an off day if the reason is sudden?

How to support a colleague who finds meetings extremely tiring?

Keeping a retro style to sci-fi spaceships?

"... to apply for a visa" or "... and applied for a visa"?

Why can't wing-mounted spoilers be used to steepen approaches?

Store Dynamic-accessible hidden metadata in a cell

how can a perfect fourth interval be considered either consonant or dissonant?

Can the DM override racial traits?

Deal with toxic manager when you can't quit

Could an empire control the whole planet with today's comunication methods?

Identify 80s or 90s comics with ripped creatures (not dwarves)

Mortgage adviser recommends a longer term than necessary combined with overpayments

Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)

What is the padding with red substance inside of steak packaging?

Intergalactic human space ship encounters another ship, character gets shunted off beyond known universe, reality starts collapsing

What other Star Trek series did the main TNG cast show up in?

Button changing its text & action. Good or terrible?

Fixing different display colors within string

How did the crowd guess the pentatonic scale in Bobby McFerrin's presentation?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

Do warforged have souls?

Match Roman Numerals

Nested ellipses in tikzpicture: Chomsky hierarchy

Can withdrawing asylum be illegal?



How to group decimal places as well?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Do we need more moderators?












0















I want to get x = 1,234,567,890.098,765,432,1.



#include <iostream>
#include <string>
#include <iomanip>
#include <locale>
using namespace std;


struct separated : numpunct<char>
{
string do_grouping() const { return "3"; }
};


int main()
{
const double x = 1234567890.0987654321;
locale our_local(cout.getloc(), new separated);
cout.imbue(our_local);
cout << fixed;
cout << setprecision(10);
cout << "x = " << x << endl;
return 0;
}


Output: x = 1,234,567,890.0987654321



Expected output: x = 1,234,567,890.098,765,432,1



It will be much better if you can make it more general as follows,





  • x = 1'234'567'890.098'765'432'1

  • x = 1_234_567_890.098_765_432_1


The decimal point is dot (US-EN).



Question



How to group decimal places as well?









share



























    0















    I want to get x = 1,234,567,890.098,765,432,1.



    #include <iostream>
    #include <string>
    #include <iomanip>
    #include <locale>
    using namespace std;


    struct separated : numpunct<char>
    {
    string do_grouping() const { return "3"; }
    };


    int main()
    {
    const double x = 1234567890.0987654321;
    locale our_local(cout.getloc(), new separated);
    cout.imbue(our_local);
    cout << fixed;
    cout << setprecision(10);
    cout << "x = " << x << endl;
    return 0;
    }


    Output: x = 1,234,567,890.0987654321



    Expected output: x = 1,234,567,890.098,765,432,1



    It will be much better if you can make it more general as follows,





    • x = 1'234'567'890.098'765'432'1

    • x = 1_234_567_890.098_765_432_1


    The decimal point is dot (US-EN).



    Question



    How to group decimal places as well?









    share

























      0












      0








      0








      I want to get x = 1,234,567,890.098,765,432,1.



      #include <iostream>
      #include <string>
      #include <iomanip>
      #include <locale>
      using namespace std;


      struct separated : numpunct<char>
      {
      string do_grouping() const { return "3"; }
      };


      int main()
      {
      const double x = 1234567890.0987654321;
      locale our_local(cout.getloc(), new separated);
      cout.imbue(our_local);
      cout << fixed;
      cout << setprecision(10);
      cout << "x = " << x << endl;
      return 0;
      }


      Output: x = 1,234,567,890.0987654321



      Expected output: x = 1,234,567,890.098,765,432,1



      It will be much better if you can make it more general as follows,





      • x = 1'234'567'890.098'765'432'1

      • x = 1_234_567_890.098_765_432_1


      The decimal point is dot (US-EN).



      Question



      How to group decimal places as well?









      share














      I want to get x = 1,234,567,890.098,765,432,1.



      #include <iostream>
      #include <string>
      #include <iomanip>
      #include <locale>
      using namespace std;


      struct separated : numpunct<char>
      {
      string do_grouping() const { return "3"; }
      };


      int main()
      {
      const double x = 1234567890.0987654321;
      locale our_local(cout.getloc(), new separated);
      cout.imbue(our_local);
      cout << fixed;
      cout << setprecision(10);
      cout << "x = " << x << endl;
      return 0;
      }


      Output: x = 1,234,567,890.0987654321



      Expected output: x = 1,234,567,890.098,765,432,1



      It will be much better if you can make it more general as follows,





      • x = 1'234'567'890.098'765'432'1

      • x = 1_234_567_890.098_765_432_1


      The decimal point is dot (US-EN).



      Question



      How to group decimal places as well?







      c++





      share












      share










      share



      share










      asked 1 min ago









      Artificial Hairless ArmpitArtificial Hairless Armpit

      5,06411243




      5,06411243






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f484591%2fhow-to-group-decimal-places-as-well%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f484591%2fhow-to-group-decimal-places-as-well%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Can't compile dgruyter and caption packagesLaTeX templates/packages for writing a patent specificationLatex...

          Schneeberg (Smreczany) Bibliografia | Menu...

          Hans Bellmer Spis treści Życiorys | Upamiętnienie | Przypisy | Bibliografia | Linki zewnętrzne |...