Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RobertD63

macrumors 6502
Original poster
Feb 17, 2008
403
42
A place
Im reading this book, and it teaches Obj-c in a way so you dont need any prior knowledge of C or any other languages. So Im on the 4th chapter right after classes and methods and ivars. Data types and expressions. Do I really need to know this? Its really confusing. For example here is a line for the book:
If the first digit of the integer value is 0, the integer is con- sidered to be expressed in octal notation—that is, in base 8. In this case, the remaining dig- its of the value must be valid base 8 digits and, therefore, must be 0–7. So to express the value 50 in base 8 in Objective-C, which is equivalent to the value 40 in decimal, the no- tation 050 is used. Similarly, the octal constant 0177 represents the decimal value 127 (1 × 64 + 7 × 8 + 7)

What?!?! Now thats confusing. :eek:
 
Octal isn't used very much in iPhone development. But there's not much to it. Almost the same as hex, base 16. You have a leading character or phrase that indicates the type of the number. In hex it's 0x, in octal it's 0. Then you have digits after that in the numbering scheme. In hex they go from 0 - F, in octal they go from 0 - 7.

int fifty = 0x32;
int sixty = 074;

Re-read what I said and re-read the text you quoted.

This octal notation is used in C, C++, and Objectve-C. Don't know if other languages use it.
 
Stuff like this some people may have to use often, I myself never had to mess with it but its always good to know it exists so that you are aware of it and can reference it if need be.


There are lots of things in programming you may never use or have to reference because you don't use them enough to remember them.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.