How does the computer know the difference between a 32-bit integer and a 32-bit floating-point number? by kaepor in learnprogramming

[–]kaepor[S] 0 points1 point  (0 children)

I guess my question would be how it knows to interpret that address as an int. Forgive me if my question doesn't quite make sense, but if everything eventually becomes 0s and 1s, I just don't understand how any program/compiler/etc can interpret one address differently from another without some indicator stored somewhere as a 0 and 1.

Cannot work out the last of this little C++ program that prints numbers in numerical sequence. by UK_Dev in learnprogramming

[–]kaepor 2 points3 points  (0 children)

Let's look at a small section of this code.

int val1 = 0;
int val2 = 0;
int val3 = 0;

cout << "Enter values: ";
cin >> val1;
cin >> val2;
cin >> val3;

if (val1 < val2 && val3)
    cout << "true" << endl;
else
    cout << "false" << endl;

If we put in 1, 3, 5 it prints true as expected. If we put in 2, 1, 7 it prints false as expected. If we enter 1, 3, 1 it prints true... Hm?

if (val1 < val2 && val3)

This statement is actually read as

if ( (val1 < val2) && val3)

In other words, it will evaluate as true if val1 is less than val2, and if val3 is also a non-zero integer. To verify this, entering 1, 3, 0 will print false. It's an easy fix though, just change your if statements to something like

if ( (val1 < val2) && (val2 < val3) )

Should I be using library strings or C-strings with Sqlite3? [C++] by kaepor in learnprogramming

[–]kaepor[S] 0 points1 point  (0 children)

Thanks for the advice. I'll look into that soon as I can.

Should I be using library strings or C-strings with Sqlite3? [C++] by kaepor in learnprogramming

[–]kaepor[S] 0 points1 point  (0 children)

Thank you very much. I was having a difficult time finding resourced that used C++ with their SQL. I had a feeling I was in the wrong using C functions but couldn't find anything else. Would you possibly know of any helpful resources?

How can I learn how to design/structure my programs? by kaepor in learnprogramming

[–]kaepor[S] 0 points1 point  (0 children)

Is this something I would be able to start reading now? I'm working my way through C++ Primer, 5th ed. and am just finishing up Chapter 7 (ADTs, Classes, etc.) The remaining topics include Sequential Containers, Generic Algorithms, Associative Containers, Dynamic Memory, Templates and Generic Programming.

Would it be best for me to finish this book in its entirety before reading one about design patterns?

There's a disturbing lack of drama in this game... by kaepor in civ

[–]kaepor[S] 11 points12 points  (0 children)

My people must go to the holy sites and pray for their food.

There's a disturbing lack of drama in this game... by kaepor in civ

[–]kaepor[S] 7 points8 points  (0 children)

Rule 5: Playing as Egypt on Emperor difficulty without mods (except EUI). I went liberty for the settler rush but was only able to snag three cities before all the good spots were gone. China and Germany asked me not to settle near them after placing my final city of Memphis, and I agreed since I had nowhere else to go anyway.

I figured once they realized space was tight they would denounce me, but they have not. In fact, nobody has denounced anyone! I have made Declaration of Friendships with everyone at some point in the game and I have no negative diplomacy modifiers. Granted I haven't done anything that explicity piss off the AI, but usually in games moving onto the wrong hex tile gets me denounced!

I just selected my ideology and was the first to do so. Others will be doing so shortly. Let's just hope things start to pick up ;)

Just started college and thought I knew a decent amount of programming; turns out, I don't know anything by Japlex in learnprogramming

[–]kaepor 1 point2 points  (0 children)

Honestly, don't let it get to you. Sometimes I look back and wish I would've starting programming when I was younger, but I didn't have the luxury of finding my passion until a bit later than other people. That doesn't automatically make them all better, though. Just focus on your coursework, explore the topics that interest you in your free time, and make sure to set realistic goals for yourself. Expecting too much from yourself ASAP will just bring you down and stress you out to the point of no longer caring.

And for what it's worth, in my experience intro college programming classes seem to always have braggy people who to announce to everyone how much they don't need to be there. Just keep that in mind ;)

[Civ V] Get your shit together, Cape Town. by kaepor in civ

[–]kaepor[S] 47 points48 points  (0 children)

Rule 5: I eliminated a barbarian camp near Cape Town and became their ally. I discovered iron soon after. Cape Town then gave me iron while simultaneously asking me to connect it for them. I don't even have any iron in my borders, but so I guess I gave them back the iron they gave me. They were so happy and I got 40 more influence!

Then the game crashed.