• 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: Jeremy Pereira <email@hidden>
  • Date: Wed, 04 Jun 2014 15:09:40 +0100

I think this got bounced by my mail system, apologies if it is a repost.


On 3 Jun 2014, at 22:16, Ron Hunsinger <email@hidden> wrote:

>
> Quotient/remainder:
> -	In Swift, a % b ignores the sign of b. A non-zero remainder has the same sign as a.
> -	Ruby does it right; A non-zero remainder has the same sign as the divisor.
>

Well, it depends on how division works.  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.

 _______________________________________________
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


  • Follow-Ups:
    • Re: swift and objective-c
      • From: Roland King <email@hidden>
    • Re: swift and objective-c
      • From: Scott Ribe <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>)

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