• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Mod (%) function in C/Objective-C?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mod (%) function in C/Objective-C?


  • Subject: Re: Mod (%) function in C/Objective-C?
  • From: Scott Ribe <email@hidden>
  • Date: Mon, 11 Aug 2014 15:24:08 -0600

On Aug 11, 2014, at 3:03 PM, Dave <email@hidden> wrote:

> My conclusion is (a % b) in C is a remainder operator and NOT modulo operator.

Yes. The first edition of K&R mistakenly referred to it as modulus (apparently based on the PDP-11 instruction which was similarly misnamed). The second edition lists it in the index only under "modulus", yet refers to it exclusively as "remainder" in the text. All the later reference works I have refer to it as remainder, but calling it "mod" became an ingrained habit before the correction, and now that mistake is replicated across vast numbers of web sites. K&R C stated that the direction of truncation and sign of result were machine-dependent for negative operands. The C99 standard tightened that up, making % into a well-specified remainder operator.

--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
(303) 722-0567 voice





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Mod (%) function in C/Objective-C?
      • From: Steve Sisak <email@hidden>
    • Re: Mod (%) function in C/Objective-C?
      • From: Dave <email@hidden>
References: 
 >Mod (%) function in C/Objective-C? (From: Dave <email@hidden>)
 >Re: Mod (%) function in C/Objective-C? (From: Keary Suska <email@hidden>)
 >Re: Mod (%) function in C/Objective-C? (From: Scott Ribe <email@hidden>)
 >Re: Mod (%) function in C/Objective-C? (From: Dave <email@hidden>)

  • Prev by Date: Re: Mod (%) function in C/Objective-C?
  • Next by Date: Re: Mod (%) function in C/Objective-C?
  • Previous by thread: Re: Mod (%) function in C/Objective-C?
  • Next by thread: Re: Mod (%) function in C/Objective-C?
  • Index(es):
    • Date
    • Thread