Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
373 views
in Technique[技术] by (71.8m points)

c++ - What does "1.$" mean?

I'm printing a variable using cout in Visual C++ 2010 and it shows "1.$". What does it mean?

Google does not allow searches with $ so I couldn't find the meaning.

EDIT:

The code is like this:

double func(...);

std::cout << func(...);

I haven't modified cout's defaults

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Its an infinite value with the precision set small:

#include <iostream>
#include <limits>
int main()
{
    std::cout << std::numeric_limits<double>::infinity() << "
";
    std::cout << std::numeric_limits<double>::quiet_NaN()() << "
";

    std::cout << std::setprecision(2) << std::numeric_limits<double>::infinity() << "
";
    std::cout << std::setprecision(2) << std::numeric_limits<double>::quiet_NaN() << "
";
}

This should print:

1.#INF
1.#QNAN
1.$
1.$

Edit:

From @ZoogieZork in the comments below (who pointed out that it was a precision problem).
This is directly related to this: What does floating point error -1.#J mean?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...