This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:spring2015:cprog:projects:eocehints [2015/04/19 20:39] – [the neatness of binary and octal (and hex)] wedge | haas:spring2015:cprog:projects:eocehints [2015/04/19 20:44] (current) – [0x1: more octal] wedge | ||
---|---|---|---|
Line 13: | Line 13: | ||
If you were to convert " | If you were to convert " | ||
- | If you pass that decimal 640 to the chmod() function, you'd end up with the sticky bit being set (T in other) along with user write, and NOTHING else. Not 640 as we desire. | + | If you pass that decimal 640 to the chmod() function, you'd end up with the sticky bit being set (T in other) along with user write, and NOTHING else. Not 0640 as we desire, but instead 01200. |
So, entering 640 on the command-line would not result in a direct conversion to octal 0640... some converting will be in order. | So, entering 640 on the command-line would not result in a direct conversion to octal 0640... some converting will be in order. | ||
Line 53: | Line 53: | ||
As you can see, even if you had a 0640, the leading zero would be dropped in the conversion, because **atoi(3)** is apparently only cognizant of decimal values (and good, because that would have taken the fun out of this particular problem... you stand to learn some important things by working through this process). | As you can see, even if you had a 0640, the leading zero would be dropped in the conversion, because **atoi(3)** is apparently only cognizant of decimal values (and good, because that would have taken the fun out of this particular problem... you stand to learn some important things by working through this process). | ||
- | And also, do you see that regardless of displaying it in octal, decimal, or hex, it is the same value? They' | + | And also, do you see that regardless of displaying it in octal, decimal, or hex, it is the same value? They' |
> Why doesn' | > Why doesn' |