Jump to content
  • Advertisement
Sign in to follow this  
PulsarSL

C++ Variable Types

This topic is 4677 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I wrote this program to compute pi, but it's not of much value unless I can get more than 5 decimal places (all my result turns out to be 5, even though I used long doubles [supposed to have 19 decimal places??]). Am I doing something wrong with my source? If you run it, use at least 100,000 cycles, without screen drawing. Thanks, PulsarSL source + binary: http://rapidshare.de/files/4481396/main.zip.html

Share this post


Link to post
Share on other sites
Advertisement
All you need to do is insert the line "cout.precision(19);" before you print the result. Cout by default truncates floats to whatever number of decimal places it defaults to.

Share this post


Link to post
Share on other sites
Quote:
Original post by stro
All you need to do is insert the line "cout.precision(19);" before you print the result. Cout by default truncates floats to whatever number of decimal places it defaults to.


Thanks, works perfectly!

Let me ask one more question, though. Is there any way I can either a)increase the number of decimal digits, or b) define some sort of custom variable type that allows more decimial digits than 19?

PulsarSL

Share this post


Link to post
Share on other sites
Download a multiprecision library. A quick web search should provide you with several options.

Share this post


Link to post
Share on other sites
Quote:
Original post by Fruny
Download a multiprecision library. A quick web search should provide you with several options.


Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!