Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8608889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:44:01+00:00 2026-06-12T03:44:01+00:00

By full precision I mean that there won’t be a case where the right

  • 0

By “full precision” I mean that there won’t be a case where the right result differs from the one I’ve calculated with my C# program.

I’ve checked this by running the same tests under a C# and C++ (without using cout.precision()). I’m sure the 2 variants of my program under C# and C++ act similarly on the same tests.

Sample code on C#.

double a;
//...code...
Console.WriteLine(a.ToString(CultureInfo.InvariantCulture));

The same but on C++.

double a;
//...code...
cout << a << endl;

Actually my C++ program without cout.precision() failed and C# with nothing but Console.WriteLine() passed.

I know that this happens because my C++ program truncates the number somehow (maybe magically) and precision is lost. But does passing all the tests mean that C# always prints a doulbe variable with full precision?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:44:02+00:00Added an answer on June 12, 2026 at 3:44 am

    If you format your double with the “R” format specifier, you get a “round-trip” representation. See http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx#RFormatString for details. Usage:

    string s = someDoubleValue.ToString("R");
    

    The default format specifier, if none is specified, is “G” (General), which “converts a number to the most compact of either fixed-point or scientific notation, depending on the type of the number and whether a precision specifier is present.” See http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx#GFormatString for details. If no precision specificer is supplied, double gets 15 digits of precision, so using “G” offers the possibility of a loss of precision.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to output the value of a double in it's full precision. However,
Full Question: From a child table linked to a row in its grandparent table
The full message that I got on the console is: Invalid memory access of
i have a full datetime object that i need to pass in as a
Are there any free-to-use libraries for .NET so that I can read Canon's raw
I want to get the current date (full date with precision to seconds), and
full explanation: I'm working on a project to generate twitter links that post over
Full Program: Option Strict On : Option Explicit On Module Module1 Sub Main() 'System.Diagnostics.Debug.Listeners.Add(New
By referring to How do I print a double value with full precision using
I'm looking for a full text search algorithm that will allow to find similar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.