Re: swift and objective-c
Re: swift and objective-c
- Subject: Re: swift and objective-c
- From: Aaron Montgomery <email@hidden>
- Date: Thu, 05 Jun 2014 08:02:15 -0700
On Jun 5, 2014, at 6:33 AM, Scott Ribe <email@hidden> wrote:
>
> On Jun 5, 2014, at 3:04 AM, Jeremy Pereira <email@hidden> wrote:
>
>> If I set y to -3, the definition becomes
>>
>> "The modulo operation is precisely defined, x mod -3 results in a positive integer between 0 and -4"
>>
>> That is clearly nonsense.
>
> It is not nonsense; it is the definition of modulo; look it up. (For instance: The Art of Computer Programming 3rd Ed Volume 1, Knuth, page 39; or Introduction to Algorithms 2nd Ed, Cormen, Leiserson, Rivest, Stein, page 851.)
Don’t have Knuth with me, but CLR 3rd edition requires the divisor to be positive and does not require the remainder (their term) or residue (their alternative term) to be positive (it requires it to be between 0 and one less than the divisor, inclusive).
Jeremy certainly has a point, as written, the statement becomes
“The modulo operation is precisely defined, x mod -3 results in a positive integer between 0 and -4”
means that it doesn’t exist (there aren’t any positive integers between 0 and -4. In fact as written, it won’t work for all positive divisors as well For example we would expect 4 mod 2 = 0, but under the definition, “4 mod 2” would need to be a positive integer between 0 and 1. However, the only positive integer between 0 and 1 is 1 (0 is not positive).
Aaron
_______________________________________________
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