Thread: Modulous operator

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    28

    Modulous operator

    Is it true that is c99, a%b is calulated as sign(a) * (abs(a) % abs(b)) ?

    where,
    sign(a) = 1 if a is +ve
    sign(a) = -1 if a is -ve.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    From draft standard see section 6.5.5
    The C99 Draft (N869, 18 January, 1999)

    Tim S.
    Last edited by stahta01; 01-06-2012 at 10:31 AM.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    According to Modulo operation - Wikipedia, the free encyclopedia, yes. Specifically, in C (ISO 1999) result has same sign as dividend.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ternary Operator to choose which operator to use
    By cncool in forum C Programming
    Replies: 7
    Last Post: 06-27-2011, 01:35 PM
  2. Replies: 3
    Last Post: 12-09-2008, 11:19 AM
  3. Replies: 2
    Last Post: 07-07-2008, 03:46 AM
  4. Replies: 1
    Last Post: 07-07-2008, 03:38 AM
  5. Modulous problem (maths, not programming)
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 02-21-2004, 06:29 AM

Tags for this Thread