Guten morgen! O.k I’m up and ready to continue w/ this!
I say GUten Morgen because the prof said we can only blog in English, Spanish or German! And I was like oooh! I wish I spoke German but I don’t. Guten Morgen is the only thing I know I used to know hot to count in German from 1-10 but not anymore! urr. O.k so either I wrote too much on Feb 5 or I stopped writing dates again because I have NOT seen a change of date for a while.
Let’s start with formatting real numbers. How do we do it? Well to specify point notation we do this:
The part where I wrote the “2”, well that’s just an example, between those parentheses you enter the amount of numbers you want after your decimal point. I understand your number HAS to be an integer because pt something amount of #’s after your decimal pt.
fixed means it won’t be in scientific notation anymore.
showpoint will make it so that there will always be a decimal point even if the next number is just zero.
I understand you can basically just put these 3 lines anywhere but it’s good to put them right after the variable declaration.
Remember how yesterday we talked int and how when we do this: 2/5 we get zero instead of 0.4. Well that’s because that would be called integer division and integer division does NOT produce a decimal. Only integers.
OOOgh. So we’ve been talking about variables and variable types. Some of these are int and double so let’s talk about the memory they use. This takes me back to my first days of this semester, I ran into this kid and we talk about this class. He tells me he got an F on his first midterm and tells me the first question was how many bits in an integer? And I was like: “whoah!!!! I don’t know!!! What’s the answer?!” and he tells me “I still don’t know!!!!!!!!!”. So I run into Emmanuelle and I start talking and talking and try to tell him about this issue but because I can’t concentrate I never got around asking him. Next time I run into him the same thing happens, he leaves and I never get to finish the question. (O.k I’m terrible at concentrating but I couldn’t ask because I hadn’t seen the guy for a while and I just wanted to say SO MUCH words kept getting in the way of my question, gee). So the third time I try to ask him I finally spit out the darn words. He’s like: “Oh, 32bits…”. ‘Cause you know he’s like that, he never says much. But I’m like: “W0W!!!!!!!!! How did you know?!?!?” So he answers me but right there and then I get a case of the blahs. That happens to me a lot. Especially when someone shocks me the way he did I thought no one would know!!! So when I get a case of the blahs is that I only hear blah blah blah when someone’s trying to explain something to me. Luckily I manged to hear the numbers ’cause he was like how much is 4 x 8? I just go: 32 and he says “That’s it”. I knew where the 8 came from, 1 byte has 8 bits I just didn’t understand where the 4 came from. But when he finished explaining I just went W0W and didn’t ask him about it anymore. But as days passed I was reading chapter 2 and I came across this table:
I got that from the slides lol and it has copyrights obvi I did not do this table because I’ve been going on about how I know nothing!!!
That table explains everything nicely!!! The 4 came from the amount of BYTES used in an integer. On that one question my friend couldn’t answer all he had to know was that an integer uses four bytes of memory and then convert it bits!!! Using the 1byte = 8bits conversion and that was it! Hoorah! Later on the prof explained this in class (which is kinda what we were discussing right before I side tracked to my story) as well so I better not forget during the test.
Now if you wanna know the values the int can hold you just get 2^32. We covered this on my first post. teehee
So the professor asks us why is it that type long and type int have the same values? We try guessing no one guesses he gives us answer. Well it’s because There are 16 bit processors and int becomes 2bits. But when it’s a normal processor it’s 4. It all depends on the processor’s native size. ~Something like that is what I understood the prof was saying~
So this means that int is sometimes just like short and other times just like long. It all depends on the processor.
On the table you can see that some things are labeled as “Not applicable”. Well this means that any number in that range can be represented. For example, you are granted to have 7 digits although you might get more, but not less.
**Character constant, example: ‘a’, must have single quotes, must be a single character. Can’t hold more.
strings = constructed datatype from primitive datatypes. The compiler doesn’t know about them that’s why we have to write them.
Anyway that’s what I have on strings in my notebook. But I just read in the slides that the strings have to be enclosed in double quotes and that they require we write this:
I have here that space = breaks, separates data items.
February 10th, 2014
We once again begin w/ something that I have yet to understand. Oh lord, I ❤ this blog it forces me to untangle the mess in my notes ahead of time. So I just went to look it up online. O.k so the thing is that I have somethign here called an ASCII table. If I remember correctly everyone already knew what these things were except me, apparently, lol. So I didn’t bother in asking… But now I know that these tables are the American Standard Code for Information Interchange. Here’s an example:
Again we talk about booleans, I like how we repeat things in class because our memories fail constantly… What a sad truth… Pt. We said booleans are logic values, true or false, yes or no. If only zero is false then the rest is true. All the other numbers. Including positive and negative. NEVER think of negative numbers as false they’re true as well!!! Ooooh! And remember how int division gave int look at this easy way to remember stuff:
int/int = int
int/double = double
double/double = double
double/int = double
Now more abstract things in my head… Did you know this % is called modulous?
I didn’t. And you represent the remainder of integer division with it. Let’s say you wanted to divide 13 by 5. Well 13 divided by 5 equals 2 with a remainder of 3. Well what we do w/ the modulous is that we can write this 13 % 5 = 3. Knowledge acquired! Oh yeah! THe professor warned us to get used to it ’cause that’s how he’ll be writing it on the test. You know I get this strange feeling that I was supposed to know the % from grade school and somehow missed it but I wouldn’t know…
The prof mentions buffers, me = has no idea what those are. me = tired of not asking things when I don’t know. I raise my hand and ask: “What are buffers? Did you already say what they were? I’m sorry!!!” – something like that. You know it is my deadliest fear to ask something the prof JUST said (it used to happen a lot in my biological sciences lab and the prof would get upset. So I don’t want to do that anymore~~~ But I still do it all the time, luckily that was not the case this time). The prof told me buffers are great in memory and they are where we temporarily store values.
Another thing we have to learn are the precedence rules. I know what these are, they are the parentheses thing in mathematical operations. You know… the order in which you will carry out all those mathematical operations. This is what the slide says about them in algebra and programming:
Precedence rules for operators are the same as used in your algebra classes
Use parentheses to alter the order of operations
x + y * z ( y is multiplied by z first)
(x + y) * z ( x and y are added first)
So if you don’t know these or forget them learn them using this: “Please excuse my Dear Aunt Sally”
Parentheses, exponent, multiplication, division, addition, subtraction.
Moving on we talk about: Operator shorthand, this means this acc to the slides:
Some expressions occur so often that C++ contains to shorthand operators for them
All arithmetic operators can be used this way
+= count = count + 2; becomes
count += 2;
*= bonus = bonus * 2; becomes
bonus *= 2;
/= time = time / rush_factor; becomes
time /= rush_factor;
%= remainder = remainder % (cnt1+ cnt2); becomes
remainder %= (cnt1 + cnt2);
Now things keep getting complicated!! Now we talk about branching. When we branch we let the program choose between two alternatives. We implement the branch using if-else statements. These are super useful and I’m glad I learned about them!! I ,3 programming!!!!! lol…
Now more important commands to make things easier for the user. Did you know there’s a function that converts from upper case to lower case?
First of all if you wanna use it, you need to add another directive. This one:
and then you have to write the following things depending on the action you want:
to lower (‘A’) this will make it so that when the user writes A the program will lower it to a and accept it as a value for a variable.
to upper (‘a’) the opp of above
to lower (‘a’) well it’s already lowered so it stays that way
to upper (‘A’) same concept as above
So going back to booleans, the professor has this nice document about them on ecourses I still haven’t read it but I will. I know it will help me understand because so far I think it’s safe to say that I don’t understand these the way I like to understand things but because right now I’m short on time, like always… I will just talk about this little chart the prof did on the board.
A = F
B = F
A&&B = F
A | | B = F
A = F
B = F
A&&B = F
A | | B = T
A = T
B = T
A | | B = T
Yeah, some things there teaching us to think logically…
So Negation, !. The prof says negation is bad in the sense that humans are notoriously bad at dealing with notation.
Have any of you ever heard of DeMorgan? I understand I hadn’t until the prof talked about it but I’m not sure sometimes we say we haven’t heard of something and then we look at an old book or notebook and we’re like: Whoa! After I denied, denied, denied… Dang…..
Yeah I got that from wikipedia don’t know if we’re allowed to read from there but I just wanted to a quick read on who DeMorgan was. Anyway I’ll stop here and keep going when I get the chance ’cause I gotta go…. SIGHS………