• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java quesion

srvblues00

Senior member
Ok, I have a varible, say temp, with a value of 28.92. and I have a variable, temp2, with a value of 17.65.

double temp = 28.92;
double temp2 = 17.65;

Here's the calculation i'm doing:

double temp3;
temp3 = (temp/temp2);

so now temp3 should == 1.6385

what i want to be able to do is get the 1.6385 separated into different parts like this:

double a = 1;
double b = 6385;

how can i do this? I'm a java newb, so try to keep it simple. In C++ i achieved this by using the floor() function. Is there something similar here in Java? Thanks!
 
Well, obviously I could just subtract the decimal part and come out with the integer, but later this program will accecpt input from a user, so the integer and decimal parts will be different every time the user inputs data. how do i tell java to grab the integer and decimal parts of a number entered by a user? (I'm not concerned with the user input code now, just separating the parts of the number.)
 
Dude, it doesn't matter where you get the number from. The same thing will work, provided that the number entered by the user is in the temp3 variable.
 
Back
Top