Thread: manipulating the remainder of a float

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    118

    manipulating the remainder of a float

    hi im having a problem finding any stuff on the remainder of a float and how to use and seperate it form the int part of a float ie 8700/1200=7 remainder300
    i was wondering if any one could post a few links or give me an idea of how this type of thing works.

  2. #2
    Registered User
    Join Date
    Dec 2005
    Posts
    118
    ok i just found something about using a % and a / to get the remainder?
    ive spent the last half hour searching about this but still cant find anything
    if using a % and a / will alow me to store the remainder of a sum then could some one please just explain how to include it in the sum thank you again

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    int quotient = 8700/1200; // Quotient = 7
    int remainder = 8700 % 1200; // Remainder = 300
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  4. #4
    Registered User
    Join Date
    Oct 2004
    Posts
    151
    % doesn't work on reals, you must use fmod().
    System: Debian Sid and FreeBSD 7.0. Both with GCC 4.3.

    Useful resources:
    comp.lang.c FAQ | C++ FQA Lite

  5. #5
    Registered User
    Join Date
    Dec 2005
    Posts
    118
    ok thank you ill try and use the % thank you for your help

  6. #6
    Registered User
    Join Date
    Dec 2005
    Posts
    118
    yay thank you so much you just made my job so much easier.
    now all i have to do is re write the new parts into my program ive just testes a small part and it already works so much more accuratly
    again thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-13-2009, 03:25 PM
  2. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  3. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM