Monday, January 30, 2012

Before I forget...

I'm starting to have some questions about how data is stored. I mean, how is it physically possible to store data into a device? And, moreover, how is it possible to read it? For some reason I really want to understand the whole mechanism. I think I'm going to ask the professor about it next class. But I should get to work on another things right now...

Script - Done!

Okay, so, I asked the professor past week about creating a script for automatically compiling a C++ source code and linking it and he told me to just press the up arrow on my keyboard until I find the command on my terminal. Thing is, I'm too lazy to do that. I prefer to just type 5 symbols to get everything compiled and linked. So, here's the simple script I needed:

 echo "Compiling the C++ source code..."
 g++ -Wall -c SourceCode.cpp
 echo "Compilation done"
 echo "Now linking..."
 g++ -o Executable SourceCode.o
 echo "Done" 

Note to self: I'm "echoing" stuff because the g++ commands do not appear in the terminal window when running the script. I just want to know what the script is doing when I run it. And I hope compiler errors show up if anything happens.

Wednesday, January 25, 2012

My first weird error...

So, today I was just having fun with my first progam on my computer class, when suddenly I got a really weird output with it. Here it is:


[user@M110-07 Terminal]$ ./FirstProgram
Press return after entering a number.
Enter the number of pods:
100000000000000
Enter the number of peas in a pod:
If you have 2147483647 pea pods
and 134514000 peas in each pod, then
you have -134514000 peas in all the pods.


According to my professor, we need 47 bits for processing 100000000000000 in C++. Since the CPU is only 32bit, the processor can't process that number with C++. That's why  With Maple (or any other math-oriented software) is possible, but not with C++.

I just thought I'd leave here as a reminder.


Friday, January 20, 2012

First question.

I barely started my programming class today, and a question just popped into my mind:

  • How is it that we can control machines through inputs? What makes it possible?

Edit:
 Well, looking back at it, I don't think I made the right question. More precisely, "How is it that computer can compute stuff like adding numbers and processing the truth value of a boolean statement given the truth values of its components?"

There's still stuff that I don't get like how cpus work.