Showing posts with label OOP344. Show all posts
Showing posts with label OOP344. Show all posts

Saturday, 1 February 2014

OOP344 Macros Workshop

So it seems swapping int's and doubles using macros or simple, me-defined functions doesn't really change too much in terms of processing time. There is of course the possibility that I screwed up in the macro version and forgot to add something to it to speed things up, but for the most part, both version of the code process in about the same amount of time, 5 seconds and change.

my hand written function's processing time for 1 billion swaps
There we can see, nearly six seconds for swapping integers.
Macro time to swap 1 billion times
It makes sense, to me at least, that using a #define macro to do the swapping instead of writing the entire function out in long form wouldn't change the times too drastically.

I mean, a #define is only going to be pasted into the main (in this case) when called, and nothing more.




It is a little comforting that the times seem to make more sense - with double's taking a slight amount longer to process than the int's, which was the reverse of my function. I do of course leave the door open that I'm completely wrong in my coding. It was also weird to go back and write code in C style after a full semester of C++ changing everything to classes. I much prefer classes but didn't feel something this size required it.

Macro code

My function







Sunday, 26 January 2014

OOP344 FieldLen Not Zero

Between trying to figure out void pointers and the assignment, I'm quite a bit lost in C++. Partly because we've not discussed enough in class, partly because the scope of the assignment is way beyond anything I've done up to this point
After going over what the function is meant to do, I started writing some pseudo code/code in comment for the display function.

Something along these lines:

//if fieldLen !=0, blank the rest of the line
//if(fieldLen=!0)
//{
// for(int i = 0; i < fieldLen; i++)
// {
// cio::console.setCharacter('\0');
// cio::console.setPosition(row, col + i);
// cio::console.drawCharacter();
// }

 //If the cursor is in the last column position in a row, move it down a single row underneath the final
//character
//if(the aren't any columns left)
// cio::console.setPosition(row + 1, col);

I get the feeling the fieldLen is closer to correct than not, but still don't understand what I'm trying to do well enough to compile and check.

Edit is still blank at this point. Want to finish more of display first.

Sunday, 19 January 2014

OOP344 Exercise 1

Okay, I'll admit it. Using the command prompt/bash shell, even for the Windows version of  GitHub is preferable to the GUI version. Intuitive the GUI is not. At the very least, the exercise showed me just how rusty I can be with nearly a month of time between writing any programs in C++. Only the most obvious errors stood out at first (adding the '+1' to when dynamically allocating memory for a new object for instance). And then there is Git, and well, Git, like all Linux-related software that isn't an Android front-end for a phone, is not about ease of use, but function. Maybe I'll try TortoiseGit and see how different that is.

Now on to the labs and reading, woo!!

Saturday, 11 January 2014

A new blog for a new course [two even!], OOP344 and SPO600. It'll probably be just blank text for a while, until I feel like mocking up templates.

Until then, lots of programming talk. C++, Assembler, and so forth in ugly plain text.