Re: swift and objective-c
Re: swift and objective-c
- Subject: Re: swift and objective-c
- From: Scott Ribe <email@hidden>
- Date: Thu, 05 Jun 2014 09:14:11 -0600
On Jun 5, 2014, at 9:02 AM, Aaron Montgomery <email@hidden> wrote:
> 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).
True, the word "positive" is in error, and I was consistently overlooking that. Also, as you point out "between" used imprecisely. Finally, I am guilty of regurgitating something quickly without vetting it, because even given the imprecision of the statement above, x mod -3 would result in an integer "between" 0 and -2 (*not* 0 and -4) or in other words between 0 and y - sign(y) * 1, or if you prefer sign(y) * (abs(y) - 1).
So, anyway, a precise definition of x mod y (from Knuth) is:
x - y * floor(x / y)
--
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