Re: swift and objective-c
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