Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics Swift Operators Working With Operators: Part 2

How does var x = 100 + 100 - ((5 * 2) / 3) % 7 give a value of 197?

I don't understand how this example = 197. It would make sense to me if the / 3 was not there.

operators.swift
// Enter your code below

var initialScore = 8
initialScore += 1
let totalScore = !10
let isWinner = totalScore

1 Answer

Tomas Salas
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tomas Salas
Front End Web Development Techdegree Graduate 37,934 Points

hello, that has to with rules of math , and swift knows this.

so it orders math operation following this rules to get that result. swift is using Int values. reason way is, that the remainder operator cannot work with type doubles.