Formatting decimal places

D

David Harmon

On Tue, 20 Apr 2004 23:46:26 GMT in comp.lang.c++, "Claudio Puviani"
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.
 
M

Michiel Salters

Julie said:
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
 
C

Claudio Puviani

Jeff Schwab said:
Where is that topic stated?

http://www.parashift.com/c++-faq-lite/how-to-post.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
 
C

Claudio Puviani

David Harmon said:
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-lite/how-to-post.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
 
J

Jeff Schwab

Claudio said:
http://www.parashift.com/c++-faq-lite/how-to-post.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.
 
J

Julie

Jeff said:
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.
 
J

Jeff Schwab

Julie said:
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++.
 
J

Julie

Jeff said:
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
 
J

Jeff Schwab

Julie said:
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?
 
J

Jeff Schwab

Julie said:
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.
 
J

Julie

Jeff said:
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.
 
J

Jeff Schwab

(warning: various paragraphs snipped)
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 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.
 
D

Dave Moore

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

<mischievous grin>
 
J

Jeff Schwab

Dave said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top