CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Data type

  1. #1
    Join Date
    Aug 2020
    Posts
    4

    Data type

    Adding large number of double data type gives me error such as 5.0095E8. can any one help on how to display the correct result when crunching this large numbers.

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,865

    Re: Data type

    Can you explain why you think that value is an error? What value would you expect to see?
    How are you displaying the value?
    Norm

  3. #3
    Join Date
    Aug 2020
    Posts
    4

    Re: Data type

    Quote Originally Posted by Norm View Post
    Can you explain why you think that value is an error? What value would you expect to see?
    How are you displaying the value?
    l wish the answer to display all the zeros or digits.

  4. #4
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,865

    Re: Data type

    How are you displaying the value? Are you using a format() method?
    Norm

  5. #5
    Join Date
    Aug 2020
    Posts
    4

    Re: Data type

    Quote Originally Posted by Norm View Post
    How are you displaying the value? Are you using a format() method?
    I am not using the format () method. I used the method earlier it gave me what I needed but couldn't crunch it again that's why I removed the format method

  6. #6
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,865

    Re: Data type

    Can you post the code, values and the output that shows what you are talking about?
    Add comments that describe what is wrong with the current output and show what you want the output to look like.
    Norm

  7. #7
    Join Date
    Aug 2020
    Posts
    4

    Re: Data type

    Quote Originally Posted by Norm View Post
    Can you post the code, values and the output that shows what you are talking about?
    Add comments that describe what is wrong with the current output and show what you want the output to look like.
    Code:
    String dat=dateT.getText();
    String xpnd=expT.getText();
    String xpnd2=expT2.getText();
    double total;
    double expend=Double.parseDouble(xpnd);
    double expend2=Double.parseDouble(xpnd2);
    total=expend+expend2;
    int dates=dated();
    int mont=months();
    int dayy=days();
    expT2.setText(""+total);
    dateT.setText(""+digit.format(dayy)+"/"+digit.format(mont)+"/"+digit.format(dates));
    JOptionPane.showMessageDialog(null, "Total Expenditure is"+total);
    The expT field has a value 50000.0 while expT2 has 50000000.0. what I wanted is, when I add the two field variables, I should have 50050000 instead I got 5.005E7
    Last edited by 2kaud; August 9th, 2020 at 10:33 AM.

  8. #8
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,865

    Re: Data type

    Where does the code use the format() method to create the display you want to see?

    Add a println statement to print out the value of the String created by format method so you can copy and paste it here.

    Please wrap all posted code in code tags to preserve formatting and to make it easier to read. Select the code and press the # button
    Norm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)