• Starting today August 7th, 2024, in order to post in the Married Couples, Courting Couples, or Singles forums, you will not be allowed to post if you have your Marital status designated as private. Announcements will be made in the respective forums as well but please note that if yours is currently listed as Private, you will need to submit a ticket in the Support Area to have yours changed.

byte question

DeathMagus

Stater of the Obvious
Jul 17, 2007
3,790
244
Right behind you.
✟27,694.00
Gender
Male
Faith
Atheist
Marital Status
Engaged
Politics
US-Others
Just realized I may not have asked the question properly. What I am curious about is how a memory location can be read as a group of bits (byte, word, etc.) rather than only as a bit. Thanks.

Shot in the dark, here - I would think that a memory location is only assigned every 8 bits for convenience. I assume that each memory location would have at least a header(a footer might not be necessary, if each memory location has the same number of bits). If you're taking up space with headers, it wouldn't be prudent to put a header with every bit, because your overhead would skyrocket. You'd also have more seek requests, since each bit would have to be called individually. By calling whole bytes at a time, only 1 request is sent for a block of 8 bits, saving time. You might acquire some bits you don't need, but it's still more efficient in the long run.

But that's just my wild guess. I would love to be corrected if that's not right.
 
Upvote 0

Soul Searcher

The kingdom is within
Apr 27, 2005
14,799
3,846
64
West Virginia
✟47,044.00
Faith
Christian Seeker
Marital Status
Married
I can't say with certianty either but I agree that data is likely read in complete bytes. I do not think that there is header and footer information for the bytes in the memory as this could reduce the usable memory to 1/3 the total. e.g. 1 byte for header 1 byte for data 1 byte for footer.

Memory is referenced by address. When a program assigns a variable it allocates a portion of memory and then uses the address of that memory to store and retrieve the data. The pointer is also stored in memory so the program knows where to begin reading when that variable is needed.

I normally don't work at the lowest levels so my knowledge of the low level functions is spotty. In higher level languages there is not a big need to understand the very low level stuff though I am sure it would have its uses. In higher level languages the programmer needs to know the data types. Visual Basic for example uses 2 bytes for an integer so any time you define a variable as an integer it allocates 2 bytes of data memory to hold the variable then when you read the variable it reads two bytes of memory. Some variables such as strings can have variable lengths in which case there is a delimiter set up to tell the system how many bytes to read.

In C strings have a null terminator and you can reference memory directly by a memory location. It is very powerful but the programmer must know what he/she is doing or will get strange unpredictable results. In VB if you have defined an integer [2 bytes] and try to place a number that requires more than 2 bytes it will generate an overflow error. C will not but rather will write the data to memory at the given location. The result is that it overflows the defined space and flows into the next memory location which may or may not already be assigned to another variable and this is the reason for the strange and unpredictable results than can sometimes happen.
 
Upvote 0

pgp_protector

Noted strange person
Dec 17, 2003
51,893
17,793
57
Earth For Now
Visit site
✟460,000.00
Gender
Male
Faith
Christian
Marital Status
Widowed
Politics
US-Others
Bit = 1 Bit of Data
Byte = 8 Bits Of Data.

How the Memory Actually works
http://en.wikipedia.org/wiki/Dynamic_random_access_memory
Square_array_of_mosfet_cells_read.png
 
Upvote 0

pgp_protector

Noted strange person
Dec 17, 2003
51,893
17,793
57
Earth For Now
Visit site
✟460,000.00
Gender
Male
Faith
Christian
Marital Status
Widowed
Politics
US-Others
Upvote 0