brain shut down

vage

2[H]4U
Joined
Jan 10, 2005
Messages
3,038
Ok guys, this might be real simple, but I'm at a block and I can't make any progress. Here's the deal, I have two numbers that are both ints. They are separated and stored in two separate members. Now, I have to take these values and combine them to set one value later on. The problem, however, is that the first int is supposed to be the whole number part of the new double, and the second int is supposed to be the fractional part of the new double.

What I am stuck on, is how to covert the int to the fractional part so that I can add the two together to make the new double. Normally, this would be pretty simple, but there is no way of telling how many decimal places the fractional part goes out to. Any ideas, did I give enough information, anything else?
 
brute force!!!!!

Code:
float fractional = (float)int2;
while (fractional > 1)
   fractional /= 10;

XD

js
 
Is this faster?

Code:
double fractional = int2 * pow(10, - log(int2) - 1);
 
surprisingly, I didn't have the most up to date file where the data is being read in from. And they are actually already stored as a whole number and a fraction so all I had to do was add them :confused:. People don't tell me much around here.
 
Back
Top