Hey, i was wondering if there was a way to output really large decimals, either to a file or to the output stream? because when i do this:

file << setiosflags(ios::showpoint) << setiosflags(ios::fixed) << setprecision(50);

or do that with cout, the program crashes.

Have you included iomanip?

yes

The setprecision command should go before the number that is to be displayed

The program still crashes. In Windows Vista, it says "----.exe has stopped working" Why is it doing this?

It can depend on which compiler you use, sometimes you have to insert system("pause") at the end of the program... But I dont know what could be your problem.. One line is not enough to make sure what could be causing problems...

OK, if i set the precision to anything above 43, it has the error. anything less, its fine. So evidently, i can't set the precision above a certain amount. is there a workaround?

Well I think it can actually go up to 47 or 48 but it depends on the implementation no matter if you use double or long double (or float).. If you type setprecision(100) it will only go up to 47 (or something like that)

Don't think that there is a workaround though...

Well, how do programs like PiFast output such huge numbers to text files? do they have an array of variables to do it?

Don't know really, maybe through some additional libraries. I've never had no need to use such precision though...

Try with C-syntax "printf("%.50d", a); " where 'a' is the name of your variable... I dont know if it works but you can try or printf("%n.50d", a) where n is the number of decimals before the comma

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.