• 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: Keary Suska <email@hidden>
  • Date: Tue, 12 Aug 2014 08:01:24 -0600

On Aug 12, 2014, at 1:42 AM, Dave <email@hidden> wrote:

>> Maybe my brain isn't working correctly but that doesn't make sense to me. Could you show the output with both x and y shown? Now, you aren't dividing by a negative integer, are you? I believe that is undefined…

Yes, it's my brain. I just needed to see it to make sense of it.

> I’m not doing any division, the function for “myMod” is as I posted:

Well, it is the divisor I was asking about and although you aren't interested in the quotient, you are asking for division to occur.

> If you think of the number as being used as an Index into an NSArray, you can see why a true mod function is better, e.g. -1 gets you the last element, -2 the second from last and so on.

I see that you are interested in a circular index. Most of the time I find myself needing a "remainder" result more than a true modulo, so I use abs(). That definitely won't work when you need the true series.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

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

  • Prev by Date: Re: When to call super
  • Next by Date: Re: NSMenu in NSTableView column
  • Previous by thread: Re: Mod (%) function in C/Objective-C?
  • Next by thread: Re: Mod (%) function in C/Objective-C?
  • Index(es):
    • Date
    • Thread