Re: swift and objective-c
Re: swift and objective-c
- Subject: Re: swift and objective-c
- From: Scott Ribe <email@hidden>
- Date: Wed, 04 Jun 2014 08:30:06 -0600
On Jun 4, 2014, at 8:09 AM, Jeremy Pereira <email@hidden> wrote:
> You need to maintain the relationship a == a / b + a % b. That means, if you want the sign of the modulus to be the same as the divisor then -10 / 3 has to come out as -4, not -3. Now, personally, (coming from a mathematical background) I think that is how it should work, but I think many programmers would find that counter intuitive.
The modulo operation is precisely defined, x mod y results in a positive integer between 0 and y - 1. Any operation that does not adhere to that definition is not the modulo operation, and calling it such is incorrect.
The fact that K&R C referred to an incompletely-specified remainder operation as "modulus" did not make it so. The fact that some programmers (myself included on occasion) continue repeating the error to this day makes it no less incorrect. And in fact, later references I have no longer refer to % as "modulus", but rather call it the "remainder" operator.
--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
(303) 722-0567 voice
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden