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 trialDrew Warren
4,565 PointsCraig's '14' Example
Why is there a '1' in the left-most digit of Craig's example.
Why doesn't that activate some extremely large number?
Thanks!
8 Answers
Kourosh Raeen
23,733 PointsThe leftmost bit only determines the sign of the integer. By the way, the number being positive 14, I think the leftmost bit shouldn't be a 1, so that might be a mistake. Maybe Craig Dennis can clarify.
Craig Dennis
Treehouse TeacherWhoa sorry everyone I just got tagged on this! Yes there is an error you are right! I will get it added to the teacher's notes. The MSB (most significant bit) should be 0 not 1. 1 is used to denote negative.
Stephanie Youstra
18,513 PointsFYI, Craig Dennis ~ the Teacher's Note never made its way into the Teacher's Note section of this video. :-(
Quinton Rivera
5,177 PointsYes can anyone clarify I thought everything was assumed positive, but if a value is negative how will it be identified?
Kourosh Raeen
23,733 PointsHi Shelman - As I mentioned above, the most significant, leftmost, bit is used to signify the sign of the integer. If that bit is is 0 then the number is positive. If that bit is 1 the number is negative. This method of representing integers in binary is called Signed magnitude. There are other methods of representing numbers in binary. Take a look at this page: https://en.wikipedia.org/wiki/Signed_number_representations#Signed_magnitude_representation
Hope this helps.
Michael Nock
Android Development Techdegree Graduate 16,018 PointsI was wondering the same thing, assuming the integer was signed i would've assumed it to be a negative number, and assuming Java uses two's complement a very high (or low, depending on how you look at it) negative number.
Jesso James
2,380 PointsAs the binary representation of the negative number, the MSB should be 1. But, the example in video is 14(positive number) so the MSB should be 0. Could you please confirm and update it?
Drew Warren
4,565 PointsI think that we are correct. The example is wrong? I don't really know hahaha.
Catalin Circu
6,744 Pointshaving the same issue, is the example wrong or? Craig Dennis could you please share your knowledge?
nsay
6,709 PointsCraig has stated in this thread that the left most number should be 0 not 1. It was a mistake in the video.
Laurence Holmes
17,016 PointsI'm curious of another aspect of the binary system. It starts at 2^0 and continues 2^1 which would be 0 and 2 respectively, correct? Surely, binary is not incapable of representing odd numbers? How would a 1 be represented?
Michael Nock
Android Development Techdegree Graduate 16,018 Points2^0 actually equals one, not zero. Zero is the same as in decimal: 0.
%0000 = 0
%0001 = 1
%0010 = 2
%0011 = 3
%0100 = 4
%0101 = 5
%0110 = 6
etc.
dmitriychirkov
6,569 PointsFor -14 not only MSB must be 1; -14 = 11111111111111111111111111111100 14 = 100 So, -14 + 14 = 0 And 11111111111111111111111111111100 + 100 = 0