473,383 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Formatting decimal places

I trying to format my output to display a set number of decimal
places. I have been trying to use the <iomanip> setprecision(), but
that will only display the total number of digits. Can someone please
help me???? Thanks.
Jul 22 '05 #1
36 7766
Uzytkownik "Andrew" <ad*****@hqcnsg.navy.mil> napisal w wiadomosci
news:8e**************************@posting.google.c om...
I trying to format my output to display a set number of decimal
places. I have been trying to use the <iomanip> setprecision(), but
that will only display the total number of digits. Can someone please
help me???? Thanks.


Check out boost::format.

Marcin
Jul 22 '05 #2

"Andrew" <ad*****@hqcnsg.navy.mil> wrote in message
news:8e**************************@posting.google.c om...
I trying to format my output to display a set number of decimal
places. I have been trying to use the <iomanip> setprecision(), but
that will only display the total number of digits. Can someone please
help me???? Thanks.


You have to set the 'float mode' to fixed. E.g.

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

cout << fixed << setprecision(1) << 1.23456789 << '\n';

cout << fixed << setprecision(2) << 1.23456789 << '\n';

cout << fixed << setprecision(3) << 1.23456789 << '\n';

cout << fixed << setprecision(4) << 1.23456789 << '\n';

cout << fixed << setprecision(5) << 1.23456789 << '\n';

}

john


Jul 22 '05 #3
Marcin Kalicinski wrote:

Uzytkownik "Andrew" <ad*****@hqcnsg.navy.mil> napisal w wiadomosci
news:8e**************************@posting.google.c om...
I trying to format my output to display a set number of decimal
places. I have been trying to use the <iomanip> setprecision(), but
that will only display the total number of digits. Can someone please
help me???? Thanks.


Check out boost::format.

Marcin


Boost is OT in this forum.
Jul 22 '05 #4

"Andrew" <ad*****@hqcnsg.navy.mil> wrote in message
news:8e**************************@posting.google.c om...
I trying to format my output to display a set number of decimal
places. I have been trying to use the <iomanip> setprecision(), but
that will only display the total number of digits. Can someone please
help me???? Thanks.


#include <ios>
#include <iomanip>
#include <iostream>

int main()
{
double d(3.14);

std::cout << std::fixed << std::setprecision(4)
<< d << '\n';

return 0;
}

Output:

3.1400
-Mike

Jul 22 '05 #5
"John Harrison" <jo*************@hotmail.com> wrote in message
news:c63g5t$7daa2$1@ID-
You have to set the 'float mode' to fixed. E.g. cout << fixed << setprecision(1) << 1.23456789 << '\n';

cout << fixed << setprecision(2) << 1.23456789 << '\n';


The float mode is sticky, so you don't have to set it in each line, though
setting it is harmless and often a good idea for clarity if we're fixing
fixed and scientific output in the same program.

cout << fixed;
cout << setprecision(1) << 1.23456789 << '\n';
cout << setprecision(2) << 1.23456789 << '\n';
Jul 22 '05 #6
Julie <ju***@nospam.com> wrote in news:40***************@nospam.com:
Marcin Kalicinski wrote:

Uzytkownik "Andrew" <ad*****@hqcnsg.navy.mil> napisal w wiadomosci
news:8e**************************@posting.google.c om...
> I trying to format my output to display a set number of decimal
> places. I have been trying to use the <iomanip> setprecision(), but
> that will only display the total number of digits. Can someone please
> help me???? Thanks.


Check out boost::format.

Marcin


Boost is OT in this forum.


Why don't you like boost?

Strange, but I've seen other people not using it *just because* (i'm not
counting compiler issues that might arise with boost).
Why - I wonder.

cheers!
b
Jul 22 '05 #7
bartek wrote:

Julie <ju***@nospam.com> wrote in news:40***************@nospam.com:
Marcin Kalicinski wrote:

Uzytkownik "Andrew" <ad*****@hqcnsg.navy.mil> napisal w wiadomosci
news:8e**************************@posting.google.c om...
> I trying to format my output to display a set number of decimal
> places. I have been trying to use the <iomanip> setprecision(), but
> that will only display the total number of digits. Can someone please
> help me???? Thanks.

Check out boost::format.

Marcin


Boost is OT in this forum.


Why don't you like boost?


I did not express my preference for Boost in my response.

I was expressing (rather tersely) that a reference to Boost is off-topic in
this forum when there is an existing and preferred solution in C++ language.
Jul 22 '05 #8
Julie <ju***@nospam.com> wrote in news:40***************@nospam.com:
bartek wrote:

Julie <ju***@nospam.com> wrote in news:40***************@nospam.com:
> Marcin Kalicinski wrote:
>>
>> Uzytkownik "Andrew" <ad*****@hqcnsg.navy.mil> napisal w wiadomosci
>> news:8e**************************@posting.google.c om...
>> > I trying to format my output to display a set number of decimal
>> > places. I have been trying to use the <iomanip> setprecision(),
>> > but that will only display the total number of digits. Can
>> > someone please help me???? Thanks.
>>
>> Check out boost::format.
>>
>> Marcin
>
> Boost is OT in this forum.


Why don't you like boost?


I did not express my preference for Boost in my response.

I was expressing (rather tersely) that a reference to Boost is
off-topic in this forum when there is an existing and preferred
solution in C++ language.


Sorry, I overreacted to your post.

Although, I don't think that mentioning boost is off topic here at all.
Just as it's not off topic to direct an (confused?) individual to other
(more appropriate?) newsgroups, isn't it?

cheers!
b
Jul 22 '05 #9
ad*****@hqcnsg.navy.mil (Andrew) wrote in message news:<8e**************************@posting.google. com>...
I trying to format my output to display a set number of decimal
places. I have been trying to use the <iomanip> setprecision(), but
that will only display the total number of digits. Can someone please
help me???? Thanks.


I doubt you have stated things correctly, unless your version of the
STL is broken ... an example usually helps clear up such
misunderstandings. The problem is that you also need to use the
manipulator std::fixed to specify that the field has a fixed number of
decimal places. Thus the following code

#include <iostream>
#include <iomanip>

int main() {
std::cout << std::setprecision(3);
std::cout << 1.0 << ' ' << 12.47 << ' ' << 16.89567 << std::endl;
std::cout << std::fixed;
std::cout << 1.0 << ' ' << 12.47 << ' ' << 16.89567 << std::endl;
return 0;
}

should produce:
1 12.47 16.9 // think about it .. you'll figure out why
1.0000 12.4700 16.8957

HTH, Dave Moore
Jul 22 '05 #10
On Tue, 20 Apr 2004 08:45:50 -0700 in comp.lang.c++, Julie
<ju***@nospam.com> wrote,
Marcin Kalicinski wrote:

Uzytkownik "Andrew" <ad*****@hqcnsg.navy.mil> napisal w wiadomosci
news:8e**************************@posting.google.c om...
> I trying to format my output to display a set number of decimal
> places. I have been trying to use the <iomanip> setprecision(), but
> that will only display the total number of digits. Can someone please
> help me???? Thanks.


Check out boost::format.

Marcin


Boost is OT in this forum.


Where OT = "On Topic"

Jul 22 '05 #11
David Harmon wrote:

On Tue, 20 Apr 2004 08:45:50 -0700 in comp.lang.c++, Julie
<ju***@nospam.com> wrote,
Marcin Kalicinski wrote:

Uzytkownik "Andrew" <ad*****@hqcnsg.navy.mil> napisal w wiadomosci
news:8e**************************@posting.google.c om...
> I trying to format my output to display a set number of decimal
> places. I have been trying to use the <iomanip> setprecision(), but
> that will only display the total number of digits. Can someone please
> help me???? Thanks.

Check out boost::format.

Marcin
Boost is OT in this forum.


Where OT = "On Topic"


Nope. OT is the accepted "Off Topic".

From one of my other responses:
I was expressing (rather tersely) that a reference to Boost is off-topic in
this forum when there is an existing and preferred solution in C++ language.

Jul 22 '05 #12
ad*****@hqcnsg.navy.mil (Andrew) wrote in message news:<8e**************************@posting.google. com>...
I trying to format my output to display a set number of decimal
places. I have been trying to use the <iomanip> setprecision(), but
that will only display the total number of digits. Can someone please
help me???? Thanks.


Sorry .. after submitting I realized that the line

std::cout << std::setprecision(3);

in my previous post should have been

std::cout << std::setprecision(4);

I guess that is why they give you that "review before posting" option
at google 8*) .. sorry for any confusion.
Jul 22 '05 #13
Julie wrote:
David Harmon wrote:
On Tue, 20 Apr 2004 08:45:50 -0700 in comp.lang.c++, Julie
<ju***@nospam.com> wrote,
Marcin Kalicinski wrote:

Uzytkownik "Andrew" <ad*****@hqcnsg.navy.mil> napisal w wiadomosci
news:8e**************************@posting.goog le.com...

>I trying to format my output to display a set number of decimal
>places. I have been trying to use the <iomanip> setprecision(), but
>that will only display the total number of digits. Can someone please
>help me???? Thanks.

Check out boost::format.

Marcin

Boost is OT in this forum.


Where OT = "On Topic"

Nope. OT is the accepted "Off Topic".

From one of my other responses:

I was expressing (rather tersely) that a reference to Boost is off-topic in
this forum when there is an existing and preferred solution in C++ language.


Not a fan of irony, I see.

Why is it OT even to mention boost? Also, if you know of a "preferred
solution," why was it worth your time to criticize someone else, but not
worth your time to present the solution?
Jul 22 '05 #14
On Tue, 20 Apr 2004 10:41:14 -0700 in comp.lang.c++, Julie
<ju***@nospam.com> wrote,
I was expressing (rather tersely) that a reference to Boost is off-topic in
this forum when there is an existing and preferred solution in C++ language.


Boost is a collection of solutions in the C++ language. Widely accepted
and frequently preferred. Not in any way off-topic that I can see.
It does happen to be the wrong answer to the question of this thread,
but that's a different matter entirely.

Jul 22 '05 #15
David Harmon wrote:

On Tue, 20 Apr 2004 10:41:14 -0700 in comp.lang.c++, Julie
<ju***@nospam.com> wrote,
I was expressing (rather tersely) that a reference to Boost is off-topic in
this forum when there is an existing and preferred solution in C++ language.

Boost is a collection of solutions in the C++ language.


True.
Widely accepted and frequently preferred.
I don't know if that is true or not, regardless, that doesn't make it on
topic. There are plenty of other libraries out there that are equally widely
accepted and preferred, but are off topic. I'm not saying that Boost, per se,
is on or off topic, just saying that universal acceptance doesn't equate to on
topic.
Not in any way off-topic that I can see.
As I said, it is off topic because there is a perfectly suitable C++ language
solution. If there were no C++ solution, then the Boost response may have been
appropriate and on-topic.
It does happen to be the wrong answer to the question of this thread,
but that's a different matter entirely.


No, it wasn't a different matter, but entirely _the_ matter of discussion.

I know that this discussion is getting close to splitting hairs that no one
really cares about, including me, so I don't really have much more to add to
this or any other response.
Jul 22 '05 #16
Jeff Schwab wrote:

Julie wrote:
David Harmon wrote:
On Tue, 20 Apr 2004 08:45:50 -0700 in comp.lang.c++, Julie
<ju***@nospam.com> wrote,

Marcin Kalicinski wrote:

>Uzytkownik "Andrew" <ad*****@hqcnsg.navy.mil> napisal w wiadomosci
>news:8e**************************@posting.goog le.com...
>
>>I trying to format my output to display a set number of decimal
>>places. I have been trying to use the <iomanip> setprecision(), but
>>that will only display the total number of digits. Can someone please
>>help me???? Thanks.
>
>Check out boost::format.
>
>Marcin

Boost is OT in this forum.

Where OT = "On Topic"

Nope. OT is the accepted "Off Topic".

From one of my other responses:

I was expressing (rather tersely) that a reference to Boost is off-topic in
this forum when there is an existing and preferred solution in C++ language.


Not a fan of irony, I see.


I don't know what that means, so I'll leave it up to you to determine for
yourself if I'm a fan or not.

Why is it OT even to mention boost? Also, if you know of a "preferred
solution," why was it worth your time to criticize someone else, but not
worth your time to present the solution?


I wasn't specifically aware of the preferred solution, I just new that it
existed.
Jul 22 '05 #17
"David Harmon" <so****@netcom.com> wrote
On Tue, 20 Apr 2004 10:41:14 -0700 in comp.lang.c++, Julie
<ju***@nospam.com> wrote,
I was expressing (rather tersely) that a reference to Boost is off-topic in this forum when there is an existing and preferred solution in C++
language.
Boost is a collection of solutions in the C++ language. Widely accepted
and frequently preferred. Not in any way off-topic that I can see.
It does happen to be the wrong answer to the question of this thread,
but that's a different matter entirely.


It's off-topic in the same way that all other third party libraries are
off-topic, regardless of how good they may or may not be. It's not part of the
language. If we open that door, the newsgroup will be flooded with threads
about boost, QT, CommonC++, blitz, MFC, ATL, M++, Rogue Wave, wxwindows, and
dozens upon dozens of others. These libraries are NOT the core standard C++
language/libraries which is the topic of this newsgroup. This isn't to say that
they're not valid and even interesting topics elsewhere, but they are out of
place here.

Claudio Puviani
Jul 22 '05 #18


Julie wrote:
Jeff Schwab wrote:

Not a fan of irony, I see.


I don't know what that means, so I'll leave it up to you to determine for
yourself if I'm a fan or not.


But Julie, it was a *joke*!

Best, Dan.

--
http://lakeweb.net
http://ReserveAnalyst.com
No EXTRA stuff for email.

Jul 22 '05 #19
Claudio Puviani wrote:
These libraries are NOT the core standard C++
language/libraries which is the topic of this newsgroup.


Where is that topic stated?
Jul 22 '05 #20
On Tue, 20 Apr 2004 23:46:26 GMT in comp.lang.c++, "Claudio Puviani"
<pu*****@hotmail.com> wrote,
It's off-topic in the same way that all other third party libraries are
off-topic, regardless of how good they may or may not be. It's not part
of the language.
If you say that, you may as well say that all C++ code is off topic. It
isn't part of the language. Unless it is an excerpt from your vendor's
headers.
If we open that door, the newsgroup will be flooded with threads
about boost, QT, CommonC++, blitz, MFC, ATL, M++, Rogue Wave, wxwindows, and
dozens upon dozens of others.


I don't know all of those. See also the "Available C++ Libraries FAQ"
compiled by Nikki Locke. http://www.trumphurst.com/cpplibs/ or
http://purl.oclc.org/NET/C++Libraries

Some you list such as MFC and ATL are predominately off topic, as they
are mostly about interfacing to a OS platform API and the problems are
mostly API problems. But if a question about C++ happens to involve
some fragment of code from MFC, that fact alone doesn't make it off
topic.

For the rest, if they are open and available, if they are attempting to
live as standard conforming C++, then let them come! Very possibly such
a library may contain not a line of off-topic code.

Likewise, "re-invent all your own wheels" is not good advice for someone
asking how to solve problems in C++.

Of course a poster should read the FAQs "[5.8] How do I post a question
about code that doesn't work correctly?" and "[5.9] Which newsgroup
should I post my questions?" and use good judgement.

Jul 22 '05 #21
Dan Bloomquist wrote:

Julie wrote:
Jeff Schwab wrote:

Not a fan of irony, I see.


I don't know what that means, so I'll leave it up to you to determine for
yourself if I'm a fan or not.


But Julie, it was a *joke*!

Best, Dan.

--
http://lakeweb.net
http://ReserveAnalyst.com
No EXTRA stuff for email.


Zing!
Jul 22 '05 #22
Julie <ju***@nospam.com> wrote in message news:<40***************@nospam.com>...
Marcin Kalicinski wrote:

Uzytkownik "Andrew" <ad*****@hqcnsg.navy.mil> napisal w wiadomosci
news:8e**************************@posting.google.c om...
I trying to format my output to display a set number of decimal
places. I have been trying to use the <iomanip> setprecision(), but
that will only display the total number of digits. Can someone please
help me???? Thanks.


Check out boost::format.

Marcin


Boost is OT in this forum.


But redirecting people to other resources is acceptable here.
Only discussing actual problems with Boost::format would be OT.
So I'll take your remark as an advice for follow-ups.

Regards,
Michiel Salters
Jul 22 '05 #23
"Jeff Schwab" <je******@comcast.net> wrote
Claudio Puviani wrote:
These libraries are NOT the core standard C++
language/libraries which is the topic of this newsgroup.


Where is that topic stated?


http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

"Only post to comp.lang.c++ if your question is about the C++ language itself.
For example, C++ code design, syntax, style, rules, bugs, etc. Ultimately this
means your question must be answerable by looking into the C++ language
definition as determined by the ISO/ANSI C++ Standard document, and by planned
extensions and adjustments."

Clearly, this excludes third party libraries, unless they somehow made it into
the ISO/ANSI C++ Standard document.

Claudio Puviani
Jul 22 '05 #24
"David Harmon" <so****@netcom.com> wrote
"Claudio Puviani" <pu*****@hotmail.com> wrote,
It's off-topic in the same way that all other third party libraries are
off-topic, regardless of how good they may or may not be. It's not part
of the language.
If you say that, you may as well say that all C++ code is off topic. It
isn't part of the language. Unless it is an excerpt from your vendor's
headers.


As I just quoted for someone else, "Only post to comp.lang.c++ if your question
is about the C++ language itself. For example, C++ code design, syntax, style,
rules, bugs, etc. Ultimately this means your question must be answerable by
looking into the C++ language definition as determined by the ISO/ANSI C++
Standard document, and by planned extensions and adjustments." This is from the
FAQ: http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

This can't be any clearer. If it's not about the C++ language itself, it's off
topic. You can get to Chicago driving a Ford, but that doesn't mean that
discussions of Chicago are in any way germane to a conversation about Fords.
Some you list such as MFC and ATL are predominately off topic, as they
are mostly about interfacing to a OS platform API and the problems are
mostly API problems. But if a question about C++ happens to involve
some fragment of code from MFC, that fact alone doesn't make it off
topic.
If the question is about C++, the MFC fragment can be removed and the example
isolated. If the MFC fragment can't be removed, then clearly, it's an MFC issue
and not a C++ issue.
For the rest, if they are open and available, if they are attempting to
live as standard conforming C++, then let them come!
If you want to make that kind of decision, you're free to start your own
newsgroup to cater to the side discussions (and continue to come here for the
C++ topics, of course). This newsgroup already has a mandate and as guests, we
have to respect it. The mandate makes no distinction with respect to the
openness, availability, or price of third party libraries. They're all
off-topic.
Very possibly such a library may contain not a line of off-topic code.
And copying such a line of code to ask a question about it -- if it's
independent of the rest of the library -- is perfectly on-topic. However,
discussing how to use the iterators in the boost graph library, for example,
would be blatantly off topic. It's an easy concept to test: can it be discussed
without reference to documentation other than the ISO/ANSI standard? If the
answer is "no", it's off-topic.
Likewise, "re-invent all your own wheels" is not good advice for someone
asking how to solve problems in C++.
Stating that something is off-topic for this newsgroup isn't saying that the
person should reinvent the wheel. It just means that the solution needs to be
discussed elsewhere. If someone wants to use ODBC, saying that it's off-topic
doesn't mean that the person has to re-implement ODBC from scratch using only
standard C++. It just means that they need to go to a more appropriate forum.
Of course a poster should read the FAQs "[5.8] How do I post a question
about code that doesn't work correctly?" and "[5.9] Which newsgroup
should I post my questions?" and use good judgement.


Well, as I indicated above, 5.9 is very clear about what constitutes on-topic
material.

And, of course, we're all wildly violating [5.12]: "An extended flame war
against an off-topic posting is just as off-topic as the original off-topic
posting. The cure can be worse than the disease." :-)

Claudio Puviani
Jul 22 '05 #25
Claudio Puviani wrote:
"Jeff Schwab" <je******@comcast.net> wrote
Claudio Puviani wrote:
These libraries are NOT the core standard C++
language/libraries which is the topic of this newsgroup.


Where is that topic stated?

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

"Only post to comp.lang.c++ if your question is about the C++ language itself.
For example, C++ code design, syntax, style, rules, bugs, etc. Ultimately this
means your question must be answerable by looking into the C++ language
definition as determined by the ISO/ANSI C++ Standard document, and by planned
extensions and adjustments."

Clearly, this excludes third party libraries, unless they somehow made it into
the ISO/ANSI C++ Standard document.


This excludes questions about thirdy-party libraries. IMO, it is in no
way OT to direct someone to an appropriate resource.
Jul 22 '05 #26
"Jeff Schwab" <je******@comcast.net> wrote
Claudio Puviani wrote:
"Jeff Schwab" <je******@comcast.net> wrote
Claudio Puviani wrote:

These libraries are NOT the core standard C++
language/libraries which is the topic of this newsgroup.

Where is that topic stated?

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

"Only post to comp.lang.c++ if your question is about the C++ language itself. For example, C++ code design, syntax, style, rules, bugs, etc. Ultimately this means your question must be answerable by looking into the C++ language
definition as determined by the ISO/ANSI C++ Standard document, and by planned extensions and adjustments."

Clearly, this excludes third party libraries, unless they somehow made it into the ISO/ANSI C++ Standard document.


This excludes questions about thirdy-party libraries. IMO, it is in no
way OT to direct someone to an appropriate resource.


Agreed.
Jul 22 '05 #27
Jeff Schwab wrote:

Claudio Puviani wrote:
"Jeff Schwab" <je******@comcast.net> wrote
Claudio Puviani wrote:

These libraries are NOT the core standard C++
language/libraries which is the topic of this newsgroup.

Where is that topic stated?

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

"Only post to comp.lang.c++ if your question is about the C++ language itself.
For example, C++ code design, syntax, style, rules, bugs, etc. Ultimately this
means your question must be answerable by looking into the C++ language
definition as determined by the ISO/ANSI C++ Standard document, and by planned
extensions and adjustments."

Clearly, this excludes third party libraries, unless they somehow made it into
the ISO/ANSI C++ Standard document.


This excludes questions about thirdy-party libraries. IMO, it is in no
way OT to direct someone to an appropriate resource.


That last statement is true only if qualified:

....if there is no suitable implementation or construct in C++
_or_
if a C++ solution is provided in addition to the redirection.

So, this is what the original respondent should have said to make an on-topic
post:
I trying to format my output to display a set number of decimal
places. I have been trying to use the <iomanip> setprecision(), but
that will only display the total number of digits. Can someone please
help me???? Thanks.


Use std::fixed, as in

cout << std::fixed << std::setprecision(3) << 1.23456789;

Alternatively, you can look into the third party boost library, specifically
boost::format.
Jul 22 '05 #28
Julie wrote:
Jeff Schwab wrote:
Claudio Puviani wrote:
"Jeff Schwab" <je******@comcast.net> wrote
Claudio Puviani wrote:
>These libraries are NOT the core standard C++
>language/libraries which is the topic of this newsgroup.

Where is that topic stated?
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

"Only post to comp.lang.c++ if your question is about the C++ language itself.
For example, C++ code design, syntax, style, rules, bugs, etc. Ultimately this
means your question must be answerable by looking into the C++ language
definition as determined by the ISO/ANSI C++ Standard document, and by planned
extensions and adjustments."

Clearly, this excludes third party libraries, unless they somehow made it into
the ISO/ANSI C++ Standard document.


This excludes questions about thirdy-party libraries. IMO, it is in no
way OT to direct someone to an appropriate resource.

That last statement is true only if qualified:

...if there is no suitable implementation or construct in C++


Boost *is* a suitable implementation in C++.
Jul 22 '05 #29
Jeff Schwab wrote:

Julie wrote:
Jeff Schwab wrote:
Claudio Puviani wrote:

"Jeff Schwab" <je******@comcast.net> wrote
>Claudio Puviani wrote:
>
>
>>These libraries are NOT the core standard C++
>>language/libraries which is the topic of this newsgroup.
>
>Where is that topic stated?
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

"Only post to comp.lang.c++ if your question is about the C++ language itself.
For example, C++ code design, syntax, style, rules, bugs, etc. Ultimately this
means your question must be answerable by looking into the C++ language
definition as determined by the ISO/ANSI C++ Standard document, and by planned
extensions and adjustments."

Clearly, this excludes third party libraries, unless they somehow made it into
the ISO/ANSI C++ Standard document.

This excludes questions about thirdy-party libraries. IMO, it is in no
way OT to direct someone to an appropriate resource.

That last statement is true only if qualified:

...if there is no suitable implementation or construct in C++


Boost *is* a suitable implementation in C++.


I can't believe you still don't understand what I'm saying. I'll try to
clarify:

....if there is no suitable implementation in the standard C++ library or no
suitable construct in the native C++ language
Jul 22 '05 #30
Julie wrote:
Jeff Schwab wrote:
Julie wrote:
Jeff Schwab wrote:
Claudio Puviani wrote:
>"Jeff Schwab" <je******@comcast.net> wrote
>
>
>
>>Claudio Puviani wrote:
>>
>>
>>
>>>These libraries are NOT the core standard C++
>>>language/libraries which is the topic of this newsgroup.
>>
>>Where is that topic stated?
>
>
>http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
>
>"Only post to comp.lang.c++ if your question is about the C++ language itself.
>For example, C++ code design, syntax, style, rules, bugs, etc. Ultimately this
>means your question must be answerable by looking into the C++ language
>definition as determined by the ISO/ANSI C++ Standard document, and by planned
>extensions and adjustments."
>
>Clearly, this excludes third party libraries, unless they somehow made it into
>the ISO/ANSI C++ Standard document.

This excludes questions about thirdy-party libraries. IMO, it is in no
way OT to direct someone to an appropriate resource.
That last statement is true only if qualified:

...if there is no suitable implementation or construct in C++


Boost *is* a suitable implementation in C++.

I can't believe you still don't understand what I'm saying. I'll try to
clarify:

...if there is no suitable implementation in the standard C++ library or no
suitable construct in the native C++ language


And putting that construct in a namespace called "boost" makes it OT?
Jul 22 '05 #31
Jeff Schwab wrote:

Julie wrote:
Jeff Schwab wrote:
Julie wrote:

Jeff Schwab wrote:
>Claudio Puviani wrote:
>
>
>>"Jeff Schwab" <je******@comcast.net> wrote
>>
>>
>>
>>>Claudio Puviani wrote:
>>>
>>>
>>>
>>>>These libraries are NOT the core standard C++
>>>>language/libraries which is the topic of this newsgroup.
>>>
>>>Where is that topic stated?
>>
>>
>>http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
>>
>>"Only post to comp.lang.c++ if your question is about the C++ language itself.
>>For example, C++ code design, syntax, style, rules, bugs, etc. Ultimately this
>>means your question must be answerable by looking into the C++ language
>>definition as determined by the ISO/ANSI C++ Standard document, and by planned
>>extensions and adjustments."
>>
>>Clearly, this excludes third party libraries, unless they somehow made it into
>>the ISO/ANSI C++ Standard document.
>
>This excludes questions about thirdy-party libraries. IMO, it is in no
>way OT to direct someone to an appropriate resource.
That last statement is true only if qualified:

...if there is no suitable implementation or construct in C++

Boost *is* a suitable implementation in C++.

I can't believe you still don't understand what I'm saying. I'll try to
clarify:

...if there is no suitable implementation in the standard C++ library or no
suitable construct in the native C++ language


And putting that construct in a namespace called "boost" makes it OT?


I've already answered that numerous times. Just forget it.
Jul 22 '05 #32
Julie wrote:
>>>http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
>>>
>>>"Only post to comp.lang.c++ if your question is about the C++ language itself.
>>>For example, C++ code design, syntax, style, rules, bugs, etc. Ultimately this
>>>means your question must be answerable by looking into the C++ language
>>>definition as determined by the ISO/ANSI C++ Standard document, and by planned
>>>extensions and adjustments."
>>>
>>>Clearly, this excludes third party libraries, unless they somehow made it into
>>>the ISO/ANSI C++ Standard document.
>>
>>This excludes questions about thirdy-party libraries. IMO, it is in no
>>way OT to direct someone to an appropriate resource.
>
>
>That last statement is true only if qualified:
>
>...if there is no suitable implementation or construct in C++

Boost *is* a suitable implementation in C++.
I can't believe you still don't understand what I'm saying. I'll try to
clarify:

...if there is no suitable implementation in the standard C++ library or no
suitable construct in the native C++ language


And putting that construct in a namespace called "boost" makes it OT?

I've already answered that numerous times. Just forget it.


You certainly have not answered it. Sorry, you're not getting off that
easily. :)

Posting C++ code to answer a question is clearly on-topic in
comp.lang.c++. Sometimes, a solution involves more code than may be
posted comfortably, so it must be discussed in a more abstract way.
Mentioning an existing repository of C++ code is one way of having such
a discussion. In this case, neither the problem posed by the OP nor the
solution provided by Boost are platform-specific; both involve only
"pure," standard C++. The complaint you've made seems to be that the
actual code is not part of the C++ standard; I can't believe this really
is what you meant, since most of the code posted here is the original
work of individuals, not excerpted from the standard. So, it seems that
the exception (no pun) you've taken to Boost is simply that it has a
name. Had I posted the code directly here, instead of redirecting the
OP to a named body of code, would you still have claimed it off-topic?
I really would like to understand the distinction you've made, and
whether I've correctly assessed your opinion.
Jul 22 '05 #33
Jeff Schwab wrote:
I've already answered that numerous times. Just forget it.
You certainly have not answered it. Sorry, you're not getting off that
easily. :)


Getting off easy??? Look at the length of this inane thread, nothing easy
about it...
Posting C++ code to answer a question is clearly on-topic in
comp.lang.c++.
Agree.
Sometimes, a solution involves more code than may be
posted comfortably, so it must be discussed in a more abstract way.
Agree. However, if there is a less-involved and equally valid solution, then
that is what should be posted. If the more involved solution uses external
libraries, then that should be considered off-topic.
Mentioning an existing repository of C++ code is one way of having such
a discussion.
Absolutely, but it should be in the context of C++.

If someone asks about a string class, and a respondent simply states:

Look at MFC CString

that is off-topic because: there is a suitable implementation that is part of
C++.

However, that doesn't strictly mean that CString is off limits. An equally
legitimate response to the hypothetical string class question could be:

Look at the std::string class.

However, if you have some Windows-specific needs,
consider the MFC CString class because it
encapsulates a lot of XXX functionality that may
be more suitable over the std::string interface
and/or implementation. If you go that route, refer
to numerous windows-specific newsgroups for follow-up
questions.
In this case, neither the problem posed by the OP nor the
solution provided by Boost are platform-specific; both involve only
"pure," standard C++.
In and of itself, being platform-neutral does _not_ qualify something as being
on-topic in this forum. Consider OpenGL, platform-neutral, and off-topic.
The complaint you've made seems to be that the
actual code is not part of the C++ standard; I can't believe this really
is what you meant, since most of the code posted here is the original
work of individuals, not excerpted from the standard. So, it seems that
the exception (no pun) you've taken to Boost is simply that it has a
name. Had I posted the code directly here, instead of redirecting the
OP to a named body of code, would you still have claimed it off-topic?
I really would like to understand the distinction you've made, and
whether I've correctly assessed your opinion.


My 'complaint' was that the original respondent should have either posted about
std::fixed or not responded, as the OP question was about "trying to use the
<iomanip> setprecision()", of which Boost doesn't immediately apply, and is
therefore off-topic.

I realize that my original response is splitting hairs, and has decomposed into
splitting atoms -- I don't have much more to add.
Jul 22 '05 #34
(warning: various paragraphs snipped)

Julie wrote:
Sometimes, a solution involves more code than may be
posted comfortably, so it must be discussed in a more abstract way.

Agree. However, if there is a less-involved and equally valid solution, then
that is what should be posted. If the more involved solution uses external
libraries, then that should be considered off-topic.


I disagree.
If someone asks about a string class, and a respondent simply states:

Look at MFC CString

that is off-topic because: there is a suitable implementation that is part of
C++.
No, that is OT because it is platform-specific.
However, that doesn't strictly mean that CString is off limits. An equally
legitimate response to the hypothetical string class question could be:

Look at the std::string class.

However, if you have some Windows-specific needs,
consider the MFC CString class because it
encapsulates a lot of XXX functionality that may
be more suitable over the std::string interface
and/or implementation. If you go that route, refer
to numerous windows-specific newsgroups for follow-up
questions.
To me, *that* discussion would seem borderline OT. I wouldn't actually
complain about it, because it's brief, tasteful, and explicit about its
platform-specific nature.
In this case, neither the problem posed by the OP nor the
solution provided by Boost are platform-specific; both involve only
"pure," standard C++.

In and of itself, being platform-neutral does _not_ qualify something as being
on-topic in this forum. Consider OpenGL, platform-neutral, and off-topic.


You think pointing someone to OpenGL would be off-topic? I again
disagree. An in-depth discussion of OpenGL would be OT, but simply
mentioning OpenGL would not be.
My 'complaint' was that the original respondent should have either posted about
std::fixed or not responded, as the OP question was about "trying to use the
<iomanip> setprecision()", of which Boost doesn't immediately apply, and is
therefore off-topic.

I realize that my original response is splitting hairs, and has decomposed into
splitting atoms -- I don't have much more to add.


OK. Thanks for taking the time to explain your opinion. I guess we'll
agree to disagree on this one.
Jul 22 '05 #35
Jeff Schwab <je******@comcast.net> wrote in message news:<wt********************@comcast.com>...

You guys do realize that you are having this discussion in a thread
entitled, "Formatting decimal places", right?

<mischievous grin>
Jul 22 '05 #36
Dave Moore wrote:
Jeff Schwab <je******@comcast.net> wrote in message news:<wt********************@comcast.com>...

You guys do realize that you are having this discussion in a thread
entitled, "Formatting decimal places", right?

<mischievous grin>


The titles of threads about topicality rarely say "topicality."

Anyway, I think the discussion has pretty much been concluded.
Jul 22 '05 #37

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ian | last post by:
Hi guys, i'm trying to format the output of a record in access, which i am pulling from through php (odbc) and the formatting is set at 4 decimal places, which i don't want. i want currency and no...
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
8
by: nick | last post by:
printf("%lf",3.25); the result is 3.25000 i want the answer correct to 3 decimal places What should i do? thanks!
7
by: Chris | last post by:
Where can I find a fairly comprehensive list of the formatting codes used when data binding. e.g. <%# Bind("Debit", "{0:C}") %>. Specifically formatting a number to 2 decimal places. Regards, Chris.
17
by: scan87 | last post by:
Can somone please, please give me the solution for the following problem. I need to submit it on Monday. Write a global function called format, which formats numbers with a given number of decimal...
4
by: sparks | last post by:
In this database some of the text boxes need to be/show something like 88.9. in the table I marked them single, format 00.0 and decimal places 1 on the form I have fixed and 1 if someone types...
3
by: Nathan Sokalski | last post by:
I am using databinding to populate a dropdownlist with numeric values. Some of the values have more decimal places than others, and I only want the minimal number of decimal places necessary...
9
by: john coltrane | last post by:
Is there way to create a formatted string in a similar that is similar to sprintf? The same for printing, printf? C,D,E,F,G,N,X for currency, decimal, exponential, fixed, general, numerical,...
2
Pittaman
by: Pittaman | last post by:
Hello I am creating some crystal reports (for visual studio 2005) based on the content of certain .NET objects. I'm doing this in .NET 2.0. For one of them I'm using a Cross-table to summarize...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.