Results 1 to 6 of 6
  1. #1
    DarkoDrljaca is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default variable double problem

    I have some variable double example: 123123123,123123123, how to get a double 0,123123123....
    Thanks....

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Um
    Java Code:
    double a = 0.123123123;
    maybe?

    Maybe you could try to explain, a little better, what it is you really mean, and/or really want, or what it is you are actually trying to achieve.

    If what you mean is that you want only the "decimal" portion of your double do
    Java Code:
    double a = 123123,123123;
    a = a - (int) a;
    Last edited by masijade; 03-01-2009 at 10:53 PM.

  3. #3
    DarkoDrljaca is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default

    code:
    private voidjButton1ActionPerformed(java.awt.event.ActionE vent evt) {
    double d;
    double d1;
    double d2;

    d = Long.parseLong(jTextField1.getText());
    d1 = d * 100 /97;
    jTextField2.setText(String.valueOf(d1));
    }


    double d is insert by user and is 233123123123 , next
    d1 = 240333116621,6494845360824742268
    Now I must convert any variable d1 to d2 and catch d2 to look
    d2 = 0,6494845360824742268 ..... for example ....
    Sory for confusion......

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Okay? So does the above work? Because I still don't know exactly what it is you need.

  5. #5
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Java Code:
    d2 = d1 - ((long) d1);
    If the integer portion of d1 can exceed the size of a long, use BigInteger instead.

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. Replies: 3
    Last Post: 11-24-2008, 08:01 PM
  2. Double Value problem
    By sakthivel123 in forum New To Java
    Replies: 2
    Last Post: 07-10-2008, 05:18 PM
  3. Double Buffering problem
    By aprenz in forum Java Applets
    Replies: 0
    Last Post: 05-28-2008, 05:26 AM
  4. how to use session variable in my problem
    By Arif Baig in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-27-2008, 08:23 AM
  5. Replies: 3
    Last Post: 01-19-2008, 09:38 AM

Posting Permissions

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