a function to return fraction

This is a discussion on a function to return fraction within the C++ Programming forums, part of the General Programming Boards category; Hello, I need a function which returns the fraction part of a number. I mean if the input to the ...

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

    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
    21,753
    You could #include <cmath> and use std::fmod.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    177
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21