sponsoredwalk said:
I don't mean to sound like a lunatic but you're talking to someone who had to go to the depths of topology & axiomatic set theory in order to be happy with introductory real analysis properly (and just won't feel right until I've gotten through all of Bourbaki), I'm just not able to deal with memorizing a bunch of seemingly arbitrary rules without good reason as a matter of practicality - it's literally a matter of practicality that I can't...
In general I'd love to be able to poke around with this stuff & get used to it like you guys did but that procedure completely failed while simultaneously being taught by a lecturer for the reasons I've mentioned.
Real analysis and C programming are two very different disciplines, IMO, so a strategy that worked for you in analysis might not be the best course of action for programming.
Your first post in this thread was almost two months ago. If you have been in this class for that long and still have yet to write your first program, that's worrisome to me. It seems reasonable that you want to understand the basics before getting started, but taking so long to "get your hands dirty" suggests a fear of doing so.
sponsoredwalk said:
As for the arithmetic stuff on wikipedia, I know it's scattered about on wikipedia but when you are trying to piece it all together & haven't a clue what you're looking for & are unable to get answers to all the extra questions that pop up then it's pretty much useless (as it has been). I may not be learning C the right way by focusing on all of the arithmetic side of things but if you look in the notes that's what he expects (there'll be a full question on this material & rather than memorize solutions I posted here to try to understand this apparent nonsense, questions like why you are doing signed arithmetic are things I haven't found on wikipedia or from anyone in my course yet - hence posting here...) so I'm forced to do it. I'd rather try to appreciate the logic behind it but I mean as I've said I'm hitting brick walls continually, haven't a clue what the overall idea is & am just trying to get some guidance direct to the problem.
The best way to get a handle on this, IMO, is to take jackmell's advice and get familiar with a debugger. This will give you a view into the CPU so you can see the registers and memory, and see what happens for each line of code.
C and C++ have a rich set of types to use. For example, in the integral (no fractional part) types there are char, short, int, and long. Each of these, including char, has both signed and unsigned variants. The "signed" vs. "unsigned" parts determine the range of numbers that can be stored in a variable of that type.
Assuming that a char is 8 bits, an unsigned char can hold numbers in the range [0..255]. A signed char can hold numbers in the range [-128..127].
Since about the mid-90s, the int type has been 32 bits (it was 16 bits before that, corresponding to the size of registers on most personal computers). An unsigned int can hold 2
32 different values, from 0 though 2
32 - 1 (= 4,294,967,295). The signed int can hold numbers in the range -2,147,483,648..2,147,483,647.
An advantage of unsigned numbers are that you can work with numbers twice as large for the same number of bits. A disadvantage of unsigned numbers is that you don't have negative numbers if you need them.
sponsoredwalk said:
Some immediate questions are why you need to do signed arithmetic?
If you have signed numbers, you can eliminate the need for the subtraction operation in the processor, which can reduce the amount of microcode that is needed in the CPU. I believe this is the reason. For example, instead of calculating a - b, you can do this addition: a + (-b).
sponsoredwalk said:
Where is the logic behind signed arithmetic? You mean there are more than just a 2s complement? 16s complement? 15s? 1?
I know of only two: 1's complement and 2's complement.
sponsoredwalk said:
Do I really need to memorize the entire ASCII alphabet?
No, but I have found that it's helpful to have a few ASCII codes memorized. 'A' = 65, 'B' = 66, and so on. 'a' = 97, 'b' = 98, and so on. Each lower case letter's ASCII code is 32 higher than its upper case counterpart. '0' (zero) = 48, '1' = 49, and so on.
sponsoredwalk said:
Is there not some logic behind predicting entries from it? What is the best list of sizes of data types that explains the arbitrary choices he's made for defining sizes, & how can I make the arithmetic fit? I haven't been able to find answers to these on wikipedia thus far...
The sizes of data are pretty much controlled by the register sizes, and will almost always be a power of 2: 8 bits, 16 bits, 32 bits, 64 bits.
sponsoredwalk said:
To sum it all up, is there actually a resource that will provide answers to all of the questions I've posted, both on the course and conceptually, or something extremely near it, or should I resort to memorization until the exam is over & banish C programming from my life forever?