• 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: swift and objective-c
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >swift and objective-c (From: "McLaughlin, Michael P." <email@hidden>)
 >Re: swift and objective-c (From: Roland King <email@hidden>)
 >Re: swift and objective-c (From: Ron Hunsinger <email@hidden>)
 >Re: swift and objective-c (From: Jeremy Pereira <email@hidden>)
 >Re: swift and objective-c (From: Scott Ribe <email@hidden>)
 >Re: swift and objective-c (From: Jeremy Pereira <email@hidden>)
 >Re: swift and objective-c (From: Scott Ribe <email@hidden>)
 >Re: swift and objective-c (From: Jeremy Pereira <email@hidden>)
 >Re: swift and objective-c (From: Scott Ribe <email@hidden>)
 >Re: swift and objective-c (From: Aaron Montgomery <email@hidden>)

  • Prev by Date: Re: swift and objective-c
  • Next by Date: Re: Swift JIT
  • Previous by thread: Re: swift and objective-c
  • Next by thread: Re: swift and objective-c
  • Index(es):
    • Date
    • Thread