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

Fixing different display colors within string

What does "spokes" mean in this context?

Simulating Exploding Dice

60's-70's movie: home appliances revolting against the owners

What aspect of planet Earth must be changed to prevent the industrial revolution?

Does Parliament hold absolute power in the UK?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

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

How many cones with angle theta can I pack into the unit sphere?

Variable with quotation marks "$()"

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

Is this wall load bearing? Blueprints and photos attached

Why not take a picture of a closer black hole?

Homework question about an engine pulling a train

Can we generate random numbers using irrational numbers like π and e?

Can I visit the Trinity College (Cambridge) library and see some of their rare books

Why doesn't a hydraulic lever violate conservation of energy?

Deal with toxic manager when you can't quit

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

Match Roman Numerals

number sequence puzzle deep six

Do warforged have souls?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

How to make Illustrator type tool selection automatically adapt with text length



How to group decimal places as well?



The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
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























  • Hmm... Did you mean to ask at stackoverflow? :)

    – Phelype Oleinik
    1 min ago
















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























  • Hmm... Did you mean to ask at stackoverflow? :)

    – Phelype Oleinik
    1 min ago














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 4 mins ago









Artificial Hairless ArmpitArtificial Hairless Armpit

5,06411243




5,06411243













  • Hmm... Did you mean to ask at stackoverflow? :)

    – Phelype Oleinik
    1 min ago



















  • Hmm... Did you mean to ask at stackoverflow? :)

    – Phelype Oleinik
    1 min ago

















Hmm... Did you mean to ask at stackoverflow? :)

– Phelype Oleinik
1 min ago





Hmm... Did you mean to ask at stackoverflow? :)

– Phelype Oleinik
1 min ago










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

Why does my Macbook overheat and use so much CPU and energy when on YouTube?Why do so many insist on using...

How to prevent page numbers from appearing on glossaries?How to remove a dot and a page number in the...

Puerta de Hutt Referencias Enlaces externos Menú de navegación15°58′00″S 5°42′00″O /...