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 Objective-C Basics (Retired) Fundamentals of C Operators and Expressions

Further explanation needed

i dont understand this :&

2 Answers

& is binary AND, and it returns 1 if both numbers are 1, and otherwise 0.

Here's an example:

5 & 3

5 in binary = 0101

3 in binary = 0011

0101

0011

?

0001

so 5 & 3 = 1

You should provide more information in context to what you don't understand. & is used in many ways in C and C++ and Objective-C you can do X & Y or Y && Y or eve &x or &y. Just to give you some examples.

X & Y the & us being used a sa bitwise operator to shift bits (which I believe this course doesn't talk about but you should know it exists).

if ( X && Y) { .... } means if X is true and Y is true then do whatever's in the code block.

&x or &y are part of pointers and are used to point to the memory address of a given pointer.

int myInt = 100 int *myPointerInt = &myInt;

What it means is that myPointerInt points to the same memory space as myInt. if I do this.

myInt = 110

because I am changing the value of myInt the value of myPointerInt would also change because myPointerInt points to the data that is allocated by myInt.