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

  • Home
  • SEARCH
  • 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 7066567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:05:50+00:00 2026-05-28T05:05:50+00:00

why is the Double.parseDouble making 9999999999999999 to 10000000000000000 ? For Example : Double d

  • 0

why is the Double.parseDouble making 9999999999999999 to 10000000000000000 ?
For Example :

Double d =Double.parseDouble("9999999999999999");
String b= new DecimalFormat("#.##").format(d);
System.out.println(b);

IS Printing

10000000000000000

instead it has to show 9999999999999999 or 9999999999999999.00

Any sort of help is greatly appreciated.

  • 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-05-28T05:05:50+00:00Added an answer on May 28, 2026 at 5:05 am

    double only has 15/16 digits of accuracy and when you give it a number it can’t represent (which is most of the time, even 0.1 is not accurate) it takes the closest representable number.

    If you want to represent 9999999999999999 exactly, you need to use BigDecimal.

    BigDecimal bd = new BigDecimal("9999999999999999");
    System.out.println(new DecimalFormat("#.##").format(bd));
    

    prints

    9999999999999999
    

    Very few real world problems need this accuracy because you can’t measure anything this accurately anyway. i.e. to an error of 1 part per quintillion.


    You can find the largest representable integer with

    // search all the powers of 2 until  (x + 1) - x != 1
    for (long l = 1; l > 0; l <<= 1) {
        double d0 = l;
        double d1 = l + 1;
        if (d1 - d0 != 1) {
            System.out.println("Cannot represent " + (l + 1) + " was " + d1);
            break;
        }
    }
    

    prints

    Cannot represent 9007199254740993 was 9.007199254740992E15
    

    The largest representable integer is 9007199254740992 as it needs one less bit (as its even)

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

Sidebar

Related Questions

When I run the following program: System.out.println(Double.parseDouble(99999999999999) + 1); I got: 1.0E14 How can
Right now I have double numba = 5212.6312 String.Format({0:C}, Convert.ToInt32(numba) ) This will give
As far as I can tell new Double(someString) and Double.parseDouble(someString) give me the exact
public Subclass(String[] parameters) throws IllegalArgumentException { super(Rectangle, Double.parseDouble(parameters[0]), Double.parseDouble(parameters[1]), 90, Double.parseDouble(parameters[2]), Double.parseDouble(parameters[3])); if(parameters.length !=
i get this error when i calculate the string value : Double.toString(Double.parseDouble(suggestionSortScore) - 6)
As I understand the doc, ParseDouble function made something like : Double parseDouble(String s)
Microsoft J++ does not have a Double.parseDouble() method. How do I do this?
I have the following code.... double num1 = Double.parseDouble(textArea_price.getText()); double num2 = Double.parseDouble(textArea_quantity.getText()); double
Why is twitter double encoding XML entity references? Here's an example tweet: xml entity
I'd like double quotes to appear within the following string so it looks like:

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.