Eat. Sleep. Code: The Computer Programming Thread, Ver. 010

But you get much quicker at realizing what you’ve done!

I know this is a computer programming thread, but would it be too off topic if I asked how questions regarding conversions from decimal > binary > hex, two’s complement, logic gates, etc.?

Couldn’t hurt to ask, most of us went through all that stuff at some point even if we don’t use it daily

Go ahead and ask. It’s related to programming.

Taking a computer organization class?

Another job question coming up:

I’m in a bit of a conundrum here. I have an interview for a small company as an SQL data analyst tomorrow. Now, I know quite a bit about SQL and relational databases in general. I’ve used SQL quite a bit when fusing little homebrew Visual Basic applications with databases, and I designed a DB as a volunteer for a small legal consulting firm in 2008 (used a lot of SQL there too).
However, I’ve never used SQL Server. I don’t even know how to start that shit up, to be honest. I know you can invoke it through Visual Studio, but my attempts to get the SQL Management Studio component (so I can work with the SQL alone) have failed. On the original phone interview with these people, they mentioned SQL Server is used (though probably not extensively).
I’ve been meaning to make contact with these people and let them know this, but I forgot. I’ve been busy with other things aside from boning up on my general SQL skills. Now the interview is tomorrow. Should I let them know this today? As in write an email or call? The original job listed general qualities and said nothing about experience in SQL Server. Chances are interview questions will be about SQL in general.

Finally ventured outside the game/regional forums and found this thread.

I’m a youngster, a junior CS student. I’ve always had this mindset that as long as I get an IT internship, coding or not, I should be happy since I’ll be getting experience. This has faded since my last potential opportunity declined me, saying that “I was more suited for a technical position.” A friend of mine who got an internship his sophomore year said that if you’re not coding at your internship, you’re doing it wrong.
With my interests being in DB Management/Design and some App Development, should I restrict my searches to these types, even though I have the skills and knowledge for web development and more general analyst positions?

Using SSMS isnt too bad, just install a SQL Server trial and take a few minutes to sit down and poke around in it. Read a couple how to’s and you’re gtg. A lot of people lie about what they know and dont know, not knowing SSMS is worth lying about because you can pick it up quick as hell.

The problem was that I literally couldn’t install SSMS. I’m trying to reinstall SS2008 at the moment. Setup was previously giving me hell about not having powershell, but I found it and installed it. So I’m trying again. Hoping it works.
But that “not that hard” stat is good to know, especially since I didn’t contact those people.

Any advice on getting into graphics? Like 2d/3d games. I’m really tending towards this it seems.

I’m not a fan of graphics, but opengl or directx is the way to go, essentially everything uses one or the other(unless you’re super bad ass and want to write your own triangle rasterizer which is kind of a fun exercise), you’ll also need to learn shaders but I think they are relatively simple(though my class on them was garbage so I didn’t learn 'em that well). I hope you like matrix math!

That is the reason I don’t get into graphics programming so much. Fucking matrix math was my kryptonite on my path to my degree, definitely my weak point

Like linear alg matrix math. Or is matrix math its own thing?

-trolls suck-

Nevermind matrix math, I wish I could write abrashian x86 assembly code for a software renderer.

When you see integers, you typically see them represented in terms of powers of 10.

E.g. 111 = 110^2 + 110^1 + 1*10^0

Notice the ones correspond to the digits

Binary just means that the integer is represented in terms of powers of 2

To convert to binary, you basically subtract the highest power of two you can. You multiply this by 1. You keep going until you’re done.

E.g.

111 - 64 = 47 SO 111 = 1*2^6 + 47

47 - 32 = 15 so 111 = 12^6 + 12^5 + 15

15 - 8 = 7 so 111 = 12^6 + 12^5 + 1*2^3 + 7

7 - 4 = 3 so 111 = 12^6 + 12^5 + 12^3 + 12^2 + 3

3 - 2 = 1 so 111 = 12^6 + 12^5 + 12^3 + 12^2 + 12^1 + 1
= 1
2^6 + 12^5 + 12^3 + 12^2 + 12^1 + 1*2^0

so in binary, 111 is 1101111

To convert from binary to hex, start from the right and group the bits into groups of four:

0110 1111

If decinmal has 10 digits (0-9) and binary has two digits (0,1), then hex has 16 digits (0,1,2,3,4,5,6,7,8,9,a,b, c, d, e, f). The symbols that look like letters are actually extra digits, where a = 10, b = 11, c = 12, … , and f = 15.

Each group of four can be a number from 0-15, ie a hex digit. After seperating the bits, you merely substitute each group of four with the appropriate hex digit.

1111 is the binary rep for 15, which is f in hex
0110 is the binary rep for 6, which is 6 in hex

Thus, 1101 0111 is 6f in hex.
Thus 111 in decimal is 6f in hex.

To go from decimal to hex, it may be easier to use division by 16, where each quotient ends up yielding a digit of the number

so 111/16 has a quotient of 6 and remainder of 15. Since 15 < 16, we’re done
Again, 6 is 6 in hex and 15 is f, so again, we have 6f as required.

Now two’s complement is the accepted standard for representing negative values on binary digits. Here, the FIRST bit is designated to represent a positive sign if the bit is 0 or a negative sign if the bit is 1. For instance, suppose we have a 32-bit number.
Every 32-bit number is some combination of 0’s and 1’s

0111 1111 1111 1111 1111 1111 1111 1111 is the value for (2^31) - 1 , the highest positive number we can make
1000 0000 0000 0000 0000 0000 0000 0000 is -2^31
1000 0000 0000 0000 0000 0000 0000 0001 is -2^31 +1

1111 1111 1111 1111 1111 1111 1111 1111 is the value for -1.

So here’s what happens.
Suppose we have a 32-bit binary rep of a number we will represent by X.
Then, if we swap every 0 with a 1 and every 1 with a 0, we essentially flip the numbers. This new number is represented by X’
No matter what X and X’ is, when we add these two numbers we get the binary rep for -1.
So X + X’ = -1
Using algebra, this means that
X’ + 1 = -X.

thus, to get the two’s complement of a 32-bit number between -128 and 127

  1. Swap the bits
  2. Add 1
  3. Profit

For instance, suppose we want to find -5

5 in binary is 0000 0000 0000 0000 0000 0000 0000 0101. It is also 0101, but remember, we are using 32 bits. The extra zeros are just multiples of two multiplied by zero. Adding zero results in the original number, hence the two are equivalent.

Swap the bits to get 1111 1111 1111 1111 1111 1111 1111 1010
Add 1 to get 1111 1111 1111 1111 1111 1111 1111 1011

So -5 is 1111 1111 1111 1111 1111 1111 1111 1011

Yes, it is based on matrix math … essentially linear transforms from R^n to R^m. In other words, rotation, reflection, dilation, and contraction are all the result of compositions of matrices.

Honestly matrix math is pretty easy for simple things like movement and whatnot. Only when you get into cool special effects do you need to do stuff that’s tricky.

Can learn enough to do 3d in honestly a day or so.

Yeah the rules of matrix addition and multiplication aren’t difficult(though multiple multiplication can get a bit gross because it doesn’t work like other math), but the ways they are used in graphics is often pretty complex. It’s also not intuitive at all, it’s just a big jumble of numbers in a matrix that means something.

How does one start using directx/opengl?

Well here is the real question, what are you trying to make? Unless you are trying to build a knowledge and skill set for an industry job, Unity will do a better job of it than anything you can make. Unity is better than a lot of tools I’ve used in the industry. If you want to put a game on 360, then learn XNA stuff, if you want to put it on pc, or iphone, then use Unity. If you really want to play with direct X, then get visual studio express and download the direct X sdk. Then google will teach you everything you need to know. The real point is, and as a programmer I hate to admit this, that programming is not terribly important anymore in a lot of game development. There are so many good tools that great games are being made by a designer and a few artists. I am speaking of indie stuff of course, but a lot of indie games are really damn good.

I was always envious of people who just got matrices easily. Those people who could naturally think in graphics code. I have always struggled with getting it right in my head, but it came so naturally to a friend. I swear he once woke up and just started coding. A little later a new shader was finished and I have to believe that he dreamt it.

Spend some more time on linear algebra. Learn more math theory. It’s the only way you’ll overcome the obstacles. Besides more Math means you are smarter somehow. It may not be obvious, but it always helps.