Public Group

# bits, bytes bite! help

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

okay im stepping up to the plate of wonderful SDL, i got it set up and my tutorial site is code3d but heres my problem, i look at the intro and i see this newly seen byte-> bytes andf bits. can anyone explain them? i dont know hex so dont go hexing me please. oh yea and its c++

##### Share on other sites
Explain what? Binary?

##### Share on other sites
explaing bytes

i see
byte->254 and stuff and i see 8 bits make a byte and stuff i just dont understand what they are.

##### Share on other sites
Your computer stores information in memory as numbers. The smallest amount of information it comprehends, a bit, can define 2 numbers (0 or 1, usually). A byte is a sequence of 8 bits, which together can define 256 numbers.

Integers, or whole numbers, in your computers memory are probably stored as 32 bits, or 4 bytes. They can define a range of 4294967296 numbers. The number of bits or bytes a piece of information takes up determines its accuracy.

In your computer's memory, 1024 bytes together form a kilobyte, 1024 kilobytes form a megabyte, and 1024 megabytes form a gigabyte.

Hope some of that helps.

-Twilight Dragon

##### Share on other sites
Think of bits as switches.
each bit can be 0 (off) or 1 (on).
1 byte = 8 bits (this is just how they designed).
if the byte 'a' is: 0011 0110 (off off on on off on on off)
byte 'b' can be: 0011 0111 (off off on on off on on on)
Each byte has a unique order of 0s and 1s (or: each byte is a unique order of 0s and 1s), so if we do 2 in power of 8, we can see that there could be only 256 different bytes (0-255).
Bits are the "switches" that make a byte.

does it help?
pex.

##### Share on other sites
yea i suppose so how can i form my own byes and bits? and then later access cirtain parts of a byte? like say

byte1[] = { 1, 0, 1, 1, 0, 0, 1, 0 }

can i do

int mybit = byte1[1];

or hows that work?

##### Share on other sites
Quote:
 Original post by willthiswork89yea i suppose so how can i form my own byes and bits? and then later access cirtain parts of a byte? like saybyte1[] = { 1, 0, 1, 1, 0, 0, 1, 0 }can i doint mybit = byte1[1];or hows that work?

There is virtually never a reason to do that, with the possible exception of projects like OSes, drivers and other things which require low-level programming.

##### Share on other sites
okay thanks i just seen it in the cone 3d and was like where did though come from? like how do i make my own or where do they come from

##### Share on other sites
As far as I know there are two ways to directly access bits in C/C++: using bitwise logical operators (you know, |, &, ^) and using bit-field (a sort of struct, you will need to read your C/C++ reference manual). I can imagine two or three situations where this could be needed, but they rarely happen. What are you trying to do?

##### Share on other sites
well, you can come up with an encyption method using binary if you wanted to.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 18
• 12
• 12
• 11
• 9
• ### Forum Statistics

• Total Topics
634753
• Total Posts
3019146
×