Solved

stripping a double

Posted on 2002-03-24
2
226 Views
Last Modified: 2010-04-02
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
Comment
Question by:boodabelly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
GGRUNDY earned 100 total points
ID: 6893089
what about

y =  x - (int)x;
0
 
LVL 1

Author Comment

by:boodabelly
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question