Are these variable types used alot in game programming?

Started by
14 comments, last by ravengangrel 13 years ago
I'd say the answer to the OP is....it depends on what platform / SDK / API you are writing the game on.
Advertisement

So the verdict is rarely?

Rarely, but I use my socket wrenches rarely too. I may use my hammers and my ints frequently, but when I encounter a certain problem or a certain need, I really want my socket wrenches in a place I can find them.

Example: long

long long = a 64 bit integer.
unsigned long long = an unsigned 64 bit integer.

If you are dealing with something were regular 32 bits are not enough, it would be horrible to have to make your own socket wrenches from duck tape and leftover banner peels that's incompatible with the rest of the tools because the language doesn't have it supported.

Some of the variables you mentioned are probably just typedefs to make things easier to read and write.
[color="#1C2837"]short
ushort = unsigned short
[color="#1C2837"]byte
sbyte = signed byte
[color="#1C2837"]long
ulong = unsigned long
[color="#1C2837"]uint = unsigned int

[color="#1C2837"]Alot of 3rd party libraries typedef their own variables to serve this same purpose. I see alot of _int64, _uint64, t_int64, t_uint64, Sint64, Uint64, uint64 sint64, UINT64, SINT64, ns::Int64, ns::Uint64, from multiple different libraries.
[color="#1C2837"]Sooner or later, you have to ask yourself, wouldn't it be alot better if the standard library added these variables in a simple typedef, so every 3rd party library in existence doesn't have to define its own, and so we can get a consistent naming scheme?
You're probably okay with just ints when developing. Increase or decrease the amount of space you need to. Technically using an int when you could use a short is wasteful but the amount of memory you'd save is sort of trivial. I'm thinking unnecessary copying of large containers and objects is going to be a much bigger issue.

Although, I think I've used shorts for small numbers before as a sort of indicator to myself that they were only supposed to hold small values.

Nobody uses stdint.h?!
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.

Normally you just want to stick with the CPU word size to avoid packing overheads.
WINNER. [/thread]

[quote name='Hodgman' timestamp='1302369664' post='4796411']
Normally you just want to stick with the CPU word size to avoid packing overheads.
WINNER. [/thread]
[/quote]

1) The thread was about LEARNING basic variable types, not about using them.

2) This is not /b/.

This topic is closed to new replies.

Advertisement