• 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: Dave <email@hidden>
  • Date: Mon, 11 Aug 2014 22:48:55 +0100

On 11 Aug 2014, at 22:26, Scott Ribe <email@hidden> wrote:

> On Aug 11, 2014, at 3:15 PM, koko <email@hidden> wrote:
>
>> When either a or n is negative, the naive definition breaks down and programming languages differ in how these values are defined.
>
> But that is only because what you call the "naive definition" is incorrect. The actual definition is precise and covers that case, and some programming languages just do not implement it.
>

If there were an Integer mod function in the Standard C Library, hopefully, people would start using this and only use % in the case of remainder. Otherwise the temptation is to handle it specially in your code one place at a time rather than calling a function, which makes testing and maintenance a nightmare.

Dave



_______________________________________________

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


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>)
 >Re: Mod (%) function in C/Objective-C? (From: koko <email@hidden>)
 >Re: Mod (%) function in C/Objective-C? (From: Scott Ribe <email@hidden>)

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