[Question] Binary / Decimal

Posts 1–9 of 9 · Page 1 of 1
[Question] Binary / Decimal
Is it important to know how to convert binary to decimal and vice versa, when it comes to hacking or just programming of any kind?

I couldnt bring myself to process the page i just read on it because I wasn't sure whether or not it was particularly important.

Thanks in advance !
Quote Originally Posted by mookamoka3 View Post
Is it important to know how to convert binary to decimal and vice versa, when it comes to hacking or just programming of any kind?

I couldnt bring myself to process the page i just read on it because I wasn't sure whether or not it was particularly important.

Thanks in advance !
No only hexadecimal is important if you stick with programming, if you go to hardware though...
Quote Originally Posted by .::SCHiM::. View Post
No only hexadecimal is important if you stick with programming, if you go to hardware though...
do you deal with assembly in robotics?
Not Really... outputs, inputs, and a bunch of funky controllers.


@mooka: K well binary isn't super important, though you should be able to do it since it's so easy. It's just counting by powers of 2. The important thing is probably learning some basic binary operations such as shift left is multiply by 2 and shift right is divide by two. XOR, OR, and AND lol, those are more important. not reading the actual binary since programs so easily translate it to hex or dec or whatever.
Quote Originally Posted by why06 View Post
Not Really... outputs, inputs, and a bunch of funky controllers.


@mooka: K well binary isn't super important, though you should be able to do it since it's so easy. It's just counting by powers of 2. The important thing is probably learning some basic binary operations such as shift left is multiply by 2 and shift right is divide by two. XOR, OR, and AND lol, those are more important. not reading the actual binary since programs so easily translate it to hex or dec or whatever.
Thanks again :P.... js you should probably go write a book on this stuff. Your explainations are 10 times better than even learncpp.com.... so easy to understand.

and I got a pretty good understanding of the operations Would it be important to understand in assembly? i plan to learn that after i finish up with c++....in like 8 years >.>

EDIT:

The tutorial i was just looking at did a piss poor job of explaining classes...or im just too stupid to understand it. http://newdata.box.sk/bx/c/htm/ch06.htm

So my question is basically what's the point of making a class... from what i saw the same thing could be accomplished a shit load easier without the complications.

Also could you explain what accessor methods are? :x

From what i gathered theyre just different ways of accessing private variables or functions outside of a class, but im not quite sure.

thanks
Things are always easier when there is someone explaining it to you, and it's also easier to explain when you have someone to explain to. Writing a book is a lot harder, because your explaining it to yourself, and yet your writing it for someone else.

I think the 21 days Tut tried to explain classes by saying they are custom types, but I think that's a bit confusing. I would think of them as containers. Classes contain data and code for a particular object.

Think of it like this. In a FPS there are many guns, but they all work about the same. They shoot, they reload, they have ammo. A class would be a container to store all this information about a gun. In fact without it it would be very hard to organize all that imformation. But if we can just take all that data and all the things a gun does and place it in a class called GUN, we can create new guns easily by just:
Code:
GUN pistol("USP",15,50);
and now pistol is a new gun called a USP with 15 rounds in a clip and 50 extra rounds.
we can call pistol.Fire(); which would make the gun shoot and expend a round.

Now accessor methods, they aren't neccessary, but are one way to protect your code. For instance say if I was programming this game using your pistol class, but I didn't know how it worked. So I call fire like this
Code:
pistol.Fire();
pistol.ammo--;
But you see what I did wrong? I also decremented the ammo by 1. That's not right because when the pistol fires the ammo is already decremented inside the function. So I decremented it twice! That's not fair. The player only gets half as many rounds now. By making ammo private, you prevent people from screwing things up like this, also I can still find out the ammo like so.
Code:
 int ammocount = pistol.GetAmmoCount();
but I don't fuck anything up in the process. This becomes even more important where you have very sensitive variables that could crash the entire program if left unchecked. And that's why we have accessors, so people can look, but not touch, if that makes sense.
Quote Originally Posted by why06 View Post
Things are always easier when there is someone explaining it to you, and it's also easier to explain when you have someone to explain to. Writing a book is a lot harder, because your explaining it to yourself, and yet your writing it for someone else.

I think the 21 days Tut tried to explain classes by saying they are custom types, but I think that's a bit confusing. I would think of them as containers. Classes contain data and code for a particular object.

Think of it like this. In a FPS there are many guns, but they all work about the same. They shoot, they reload, they have ammo. A class would be a container to store all this information about a gun. In fact without it it would be very hard to organize all that imformation. But if we can just take all that data and all the things a gun does and place it in a class called GUN, we can create new guns easily by just:
Code:
GUN pistol("USP",15,50);
and now pistol is a new gun called a USP with 15 rounds in a clip and 50 extra rounds.
we can call pistol.Fire(); which would make the gun shoot and expend a round.

Now accessor methods, they aren't neccessary, but are one way to project your code. For instance say if I was programming this game using your pistol class, but I didn't know how it worked. So I call fire like this
Code:
pistol.Fire();
pistol.ammo--;
But you see what I did wrong? I also decremented the ammo by 1. That's not right because when the pistol fires the ammo is already decremented inside the function. So I decremented it twice! That's not fair. The player only gets half as many rounds now. By making ammo private, you prevent people from screwing things up like this, also I can still find out the ammo like so.
Code:
 int ammocount = pistol.GetAmmoCount();
but I don't fuck anything up in the process. This becomes even more important where you have very sensitive variables that could crash the entire program if left unchecked. And that's why we have accessors, so people can look, but not touch, if that makes sense.
Ohhhhh okay,so basically classes are for organization, efficiency, and to avoid certain screw ups.

And the look but cant touch thing for the accessors made perfect sense. accessors are just to see what a function would do without making any actual changes to it right?

So if you called a function that was in a private class would it be a compiler error ? So that would prevent you from accidentally changing whats inside the function?
Quote Originally Posted by why06 View Post
By making ammo private, you prevent people from screwing things up like this, also I can still find out the ammo like so.
Code:
 int ammocount = pistol.GetAmmoCount();
but I don't fuck anything up in the process. This becomes even more important where you have very sensitive variables that could crash the entire program if left unchecked. And that's why we have accessors, so people can look, but not touch, if that makes sense.

Just to contribute: the 'private', 'public' and 'protected' keywords are just for the IDE, they do nothing at all when compiled. Like why said they're just a means to prevent people from writing dirty code.

In game SDK's you can just comment out or replace them all with public and have full access to all the vars, which is sometimes needed to achieve what we basterds want.

If the text below is currently above your league do not continue on reading as it'll only make you more confused.
*why don't we have spoilers*

For example(from the top of my head, dont have SDK installed atm) Alien Swarm uses 'Commander' entities, which you have control over, however instead of using that entity they each have a Marine entity which is the actual entity that is being moved when you press wasd/move cursor etc.
Getting the commander entity is just engine->GetLocalPlayer() which returns the index, then entitylist->GetEntityByIndex(yourindex) to get access to IClientEntity.
Since the commander entity inherits from IClientEntity we can just cast that to the commander entity type(CASW_Player I think it was).

Now the problem is the commander entity doesn't move. so if we want to get our marine's position we'll need to have access to the marine entity, but there's 1 problem!
CASW_Player's GetMarine function is not virtual! that means we can't compile our code calling GetMarine without having a pointer to the original function, however the original function IS present in the SDK, and it does as much as EntityList->GetEntityFromNetworkHandle, and apparantly our CASW_Player class has a private member named m_hMarine!
Now in order to still get access to the marine we just replace the private: into public: and use EntityList->GetEntityFromNetworkHandle(m_hMarine.Value) and we'll have our marine entity! ;D Needless to say that we can get positions etc of that now.


edit: @mooka: So if you called a function that was in a private class would it be a compiler error ? So that would prevent you from accidentally changing whats inside the function?
Yes it would tell you that the variable/function you tried to access/call is protected and can not be used.
If you where to take the definitions of these words to that of a dictionary makes your wonder why they name stuff they way they do.

Yes this doesn't always work for every case in programming.

Programming is nothing more than a language itself (english)
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Need help?