x
Solved

# stripping a double

Posted on 2002-03-24
Medium Priority
233 Views
what would be the easiest way to strip the whole number of the double....ie.

37.39283

to the value of 39283

I just need to get the fraction out of it, I thought it would be simple at first by
double x = 37.39283;
double y;

y = (x % 1);

but doh......only can use that for integers.  Any other simple suggestions?

0
Question by:boodabelly

LVL 3

Accepted Solution

GGRUNDY earned 400 total points
ID: 6893089

y =  x - (int)x;
0

LVL 1

Author Comment

ID: 6893105
well damn I am dumb.......this is what I just did, but hell.....its been to long since I have done this :(.

memset(buffer, 0, 64);
sprintf(buffer, "%f", x);

if(!buffer)
{
return;
}

decimalPlace = strstr(buffer, ".");          // search for the decimal point

decimalPlace++;                                   // advance past decimal point
y = (double)strtol(decimalPlace, 0,10);

I think I will be using your's thanks
0

## Featured Post

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.