bits, bytes bite! help

Started by
11 comments, last by -Tony- 18 years, 4 months ago
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++
Advertisement
Explain what? Binary?
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.
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
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++
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.
pex.
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?
Quote:Original post by willthiswork89
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?


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.
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
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?
well, you can come up with an encyption method using binary if you wanted to.
==========================blog: http://piccahoe.phase1media.comCompany:http://phase1media.com

This topic is closed to new replies.

Advertisement