Modulus algorithm

This is a discussion on Modulus algorithm within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I'm looking for the modulus algorithm. I'm trying to make a modulus function that operates on a base N number ...

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Modulus algorithm

    I'm looking for the modulus algorithm. I'm trying to make a modulus function that operates on a base N number (represented as a string most likely) but haven't had any luck when searching for it. Links are welcome.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    I don't suppose this would work for you in some form, would it?
    Code:
    int r = a - b * (int)( (double)a / b )
    My best code is written with the delete key.

  3. #3
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    The modulus operation (as related to integers), works independently of the base.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Implement of a Fast Time Series Evaluation Algorithm
    By BiGreat in forum C Programming
    Replies: 7
    Last Post: 12-04-2007, 02:30 AM
  2. Replies: 4
    Last Post: 12-10-2006, 07:08 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

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