Thread: a function to return fraction

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    183

    a function to return fraction

    Hello,

    I need a function which returns the fraction part of a number.
    I mean if the input to the function is 5.678, I need the output to be 0.678.

    Is there a built in function to do so in C++?

    Thank you
    arian

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You could #include <cmath> and use std::fmod.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    183
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 18
    Last Post: 03-26-2008, 09:01 AM
  2. Replies: 6
    Last Post: 04-09-2006, 04:32 PM
  3. help with fraction division function
    By trippedwire in forum C++ Programming
    Replies: 6
    Last Post: 10-24-2004, 11:38 AM
  4. return value in function
    By threahdead in forum C Programming
    Replies: 2
    Last Post: 10-18-2002, 06:01 PM
  5. Rational Fraction Call to Function
    By Sharon in forum C++ Programming
    Replies: 2
    Last Post: 06-29-2002, 11:35 AM