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

Thanks....

Printable View

- 03-01-2009, 10:35 PMDarkoDrljacavariable double problem
I have some variable double example: 123123123,123123123, how to get a double 0,123123123....

Thanks.... - 03-01-2009, 10:46 PMmasijade
Um

Code:`double a = 0.123123123;`

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

Code:`double a = 123123,123123;`

a = a - (int) a;

- 03-01-2009, 11:03 PMDarkoDrljaca
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...... - 03-02-2009, 12:43 AMmasijade
Okay? So does the above work? Because I still don't know exactly what it is you need.

- 03-02-2009, 07:52 AMtoadalyCode:
`d2 = d1 - ((long) d1);`

- 03-02-2009, 09:00 AMmasijade
Ach, yeah, duh, long.