Returning the Residual

This is a discussion on Returning the Residual within the C++ Programming forums, part of the General Programming Boards category; Hi there, I would like to know whether C++ has an equivalent function to Fortran's intrinsic MOD(A, P), i.e. a ...

  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    15

    Returning the Residual

    Hi there,

    I would like to know whether C++ has an equivalent function to Fortran's intrinsic MOD(A, P), i.e. a function that returns the remainder of a division. I realise that such a function is easy to code, but wondered if such a function already exists.

    Thanks!

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    The modulo operator (%) works on integral types. You can also find a function called fmod in the <cmath> header for use with floating-point types.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with struct... not returning correct results.
    By drty2 in forum C Programming
    Replies: 7
    Last Post: 01-18-2009, 10:25 PM
  2. function returning hour in either 12 or 24 hour format
    By stanlvw in forum C Programming
    Replies: 4
    Last Post: 01-01-2008, 05:02 AM
  3. Recursion: base case returning 1, function returning 0
    By yougene in forum C Programming
    Replies: 5
    Last Post: 09-07-2007, 05:38 PM
  4. Function returning incorrect value
    By CHurst in forum C Programming
    Replies: 3
    Last Post: 12-13-2005, 12:27 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM

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