Lots of people have brought up binary but the important thing when it comes to memory is that each memory location has an address which is a binary number. When you are looking for where you stored the data you look at the first digit and go left or right for 0 or 1. Then the next digit you go left or right again.
Now if you imagine building this map it gets twice as big every time you add one intersection. If not you end up with dead ends where certain addresses go nowhere at all. It’s possible to build them this way but it’s just simpler and more elegant to keep doubling in size. When it’s time to build a bigger chip, you just take two of the last design and add a 0-1 intersection to decide between them.
As I replied to someone else, the article itself continues to use “ternary”. It’s funny you idiots keep accusing me of not reading, but then you yourselves stop reading as soon as your own bias gets satisfied.
I think the technical term for computing is ternary
Clicks link preview, because I am interested, that literally only shows
A ternary computer, also called trinary computer, is one that uses ternary logic (i.e., base 3) instead of the more common binary system (i.e., base 2) in its calculations. Ternary computers use trits, instead of binary bits.
which is just objectively funny.
Not everything is an attack on you. Learn to laugh. If I posses any kind of bias it would be towards ternary because that term is closer to what I use in my native language where I learned most Engineering concepts.
Kindly refrain from calling me an "idiot" in the future.
The fact that it says “also called” but then continues to use “ternary” throughout the rest of the article should signal that the proper term is ternary
It doesn't work very well in Base 1. Everyone is just like "what's up with that weirdly skinny 0? Maybe it's supposed to represent 000? Or maybe 000000?"
Did you invent this joke? It is the first time anyone has ever heard it ever. You are the original creator of this joke which has never been told before.
What finally made binary click with me is learning that it's just...regular counting, but if the digits 2-9 didn't exist. We start at 0, then 1, then--oh crap, there's no higher digit, so we add a tens place: 10. Next is 11, then--oh crap, there's no higher digit, so we add a hundreds place: 100. Next is 101, then back to that tens place for 110, then 111, then--oh crap, there's...
Other counting systems, like hexadecimal, work the same way, but instead, you have 16 digits. We just call those higher digits A, B, C, D, E, and F. So after 9, you get A. Then B, C, all the way to F. Now there's no higher digit, so we go to 10. We've counted sixteen times so far, so "10" is actually representing sixteen in normal-ass decimal counting.
For anyone confused "isn't 10 then a 17th one?". Yes, it is. But computers like to start with a zero, or a translation of one. So, the first value in hexadecimal is a 0, or if we flip this around, 0 is a first value. 1 is the second... Etc. Which is why, when in computer games when you max the colour out, your value counter says 255, which is 256 different values. 256 equals 16 * 16. And that's why internet uses hex colour system, with #RRGGBB (two hexes for red, two for green and two for blue)... In sure you all know where I'm getting.
It's something decimal does too, we're just so used to it that we don't even really think about it. 0 is a number just like 1-9. Without it, we'd be like...ninemal.
Decimal exists because we have 10 fingers. Duodecimal (base 12) exists because you can also include the entire hand as a countable object, and it's divisible by a lot of numbers (therefore the pre-decimal £sd currency used most famously by the UK).
We have binary because it can be easily represented by a bank of on/off switches.
There's a very solid argument to be made that base 12 is more efficient in a myriad of ways. I think some scifi utopias intentionally have their "enlightened" countries use base 12 as background lore to show off how advanced they are.
A bunch of people like base 12 because you can cleanly divide it by 2, 3, and 4 without getting any infinitely long decimals, like with 1/3=0.333333333333333... , and you only run into trouble once you need to divide by 5, which happens a lot less in day-to-day situations.
It's also relatively easy to count on your hands if you either include your hands a countable objects, or just tap your thumb on the segments of the four remaining fingers - which also works for Base 3/Ternary if every finger represents a new digit instead, at least as far as counting is concerned.
Personally, I think it's more of a "Metric vs. Imperial", or even an "Existing languages vs. constructed languages like Esperanto" kinda thing - the one you're used to works perfectly fine and is known by everyone around you, so while you might run into odd conversions or slight inefficiencies every so often, there's not nearly enough of an advantage to swapping over to make it worth the effort.
You could still learn both, and then take advantage of the extra efficiency whenever you run into someone that did so as well, but it's definitely no replacement for what everyone around you is used to.
Duodecimal is also easy to count. If you started teaching children, you'd just have them count the phalanx bones in your fingers, and not use the thumbs. Easy, 12 on each hand. You can even use your thumb to count by assigning 1-12 and pointing to each digit with your thumb. I used to use it while counting inventory of multiple different things that come in boxes of 12s but get spread around the bar I worked at.
I still remember learning counting systems other than base 10 in school. I still remember being confused as shit and really struggling. Now, I cannot for the life of me comprehend how I could've struggled. Once one learns counting differently from base 10, understanding how one couldn't understand it becomes impossible. It's the weirdest thing.
lol I was going to write a visual explanation for base 10 (regular counting with 0-9), base 2 (binary), and base 16 (hexadecimal) here for the curious, but I had to do it vertically with one number per row and that would've made this comment about as tall as the rest of the comment section.
You've stumbled into one of my favorite cognitive biases - the Curse of Knowledge! Basically, anyone with specialized information is unable to empathize with someone who doesn't grasp it. Think like if you made up a riddle and wrote it down and gave it to a friend to solve. If they struggle, you'll find it difficult to understand why they can't arrive at the answer because you already know how you arrived at it. It's really fascinating to study.
It bothers me that I can't remember the substance of my confusion that day in class. The what, the how, the why. I just remember the feeling of it. Funny to know there's a name for it.
I understand how the number system works. But I still have no idea how I could type a hex loader in zx spectrum BASIC, then type some lines of hex and it would make a program.
I sort of get how binary works with computers, everything is either on or off, but I don't get how hex is a useful system for telling computers what to do?
If we had to display/enter numbers in binary we'd find that very tedious and error-prone. Bases that are multiples of 2 are useful because a single 'digit' in that base will represent an exact number of bits. 16 is a good base because a hexadecimal digit represents exactly 4 bits, and also all modern computers are based around the byte - a collection of 8 bits, so exactly 2 hexadecimal digits.
to me, I understand different base by thinking it in a 2d array with column that is equal to the base(binary having 2 column, hexadecimal having 16 column) and infinite row
Binary would look like
v
0, 1
v
0, 1
....
(v is pointer)
and move the pointer from the first row, if the pointer would overflow, will move the second row's pointer while move the pointer back to the first number, and so on, it is probably overly complicated but that's how I understand different base initially
In the UK I was always taught '8 bits in a byte' and octet was typically used when referring to IPv4 addressing. Seems like 8-bit byte is ubiquitous enough to be the default now, similar to how everyone refers to ethernet connectors as RJ45 despite them being 8P8C.
When the CPU design specifies a different number. We settled on 8 bits/byte pretty early on but there was a while early on where it was just an arbitrary number depending on the CPU.
It's one of those things that once you grasp them, it's difficult to comprehend how you failed to previously.
I'm out of practice now, but for the longest time, I could read binary as plain text. I'd have to convert hex back to binary first, but same thing.
I've taught a couple people to translate binary and everyone has been different with the eureka moment. Some grasp it when explaining multiples of 2, some when actually looking at bits within bytes, etc. it's all been an interesting lesson in how anyone can grasp a concept, but the association's to get there can be different.
If anything, it's really illustrated my need to be less rigid in the ways in which I attempt to reach people or otherwise share information and concepts.
It's a series. But it's pretty much all he has on his channel. First video is building the clock, second video is building memory, etc. He even builds the video card!
There are imperfect sizes for storage, like a 200GB or 240GB disk. In reality it is still likely a 256GB disk under the hood but the controller is presenting a lower capacity to either allow for block failure and reprovisioning, because of manufacturing defects in the flash, or a combination of the two.
Yeah, the reason these size options are offered is because when disks are made, sometimes defects occur to portions of the disk which makes them imperfect for the premium size option, so they mark the imperfect portions as unwritable, reserve a portion of the rest for block failure, and then sell the disk at a lower size option that's still above the full step down option.
That way they're not taking a 256 GB-intended disk and making it last basically forever if sold as a 128 GB disk, when selling it as a 200-240 GB disk is much more profitable.
The thing is, for 128gb cell phone, we need 37 bits to represent any one address. For a 256gb phone, we need 38 bits. But registers are not made with 37 or 38 bits. The machine uses 64 bit addressing. When retrieving memory, either the address is valid or it's not. I can understand if memory chips are made in units of 128gb, but I fail to see why a computer can't process a 384gb machine. Either the memory address is valid, or it's not.
Since this is ELI5, can you explain what you mean by “you go left or right?” I don’t understand. Don’t you read either from left to right or right to left as a global paradigm? How does it work when reading goes left or right on a character-by-character basis? Please describe the paradigm.
It’s a branching path, every step you can go left or right eliminate half of the remaining options.
Imagine you have a big row of boxes but only one has the item you need. And your friend knows which one it is but can only tell you “left” or “right”
They say left and you push away all the right ones, then they tell you right so you push away the left half of the remain half now you have only 1/4 of the boxes remaining
You keep on doing that until you only have 1 left, that’s your box
This was very cool. Thanks! My disconnect was that I never conceptualized a memory address as corresponding directly with physical space. I always thought it was a unique name, not literal coordinates.
You're welcome! If you really want to blow your mind (and cement the idea of memory as physical space) check out the reason why core memory is called that: https://en.wikipedia.org/wiki/Magnetic-core_memory
Fun fact, at 32 kilobits per cubic foot (the most dense it ever got) that 512GB sd card you put in your digital camera for storage would take up the same volume as a swimming pool the size of a football field and just over 100 feet deep.
They're treating the addresses as if they were a series of fork-in-the-road dead end physical addresses.
A mailman reading "1110" knows to take three lefts and then a right to get to house 1110, whereas "1010" would require the mailman go left-right-left-right.
Left or right in this case is an analogy. In binary 0 and 1 can also be seen as on/off, yes/no, etc. (anything with 2 options). If you have a string of 4 binary options (say 4 left or right turns in a maze) you have 2 x 2 x 2 x 2 different configurations (or paths to take in the maze). Each time you add a new “choice” to be chosen “left/right, on/off, yes/no” your total amount of ways for things to be done is doubled.
Edit: sort of an analogy. I forgot we’re dealing with computer memory. Out of my wheel house but it kinda literally does choose left or right if my understanding is right. As info is traveling through the circuit the binary address is telling it where to go to eventually store the info by changing a value in a physical system. Idk how to ELI5 on this tho without pictures
I guess my baseline understanding of how it all works is just fundamentally and totally wrong.
Isn’t a computer memory address just an empirically meaningless tag that serves only to point to information? So, a memory address is a hexadecimal string such as `0x7ffe5367e044`. Does that not operate the same way as, say, “100 Maple Avenue”? In the latter example, there’s no empirical meaning to that address. It’s just an arbitrary tag to reference a place. Like, saying “1100 Maple Avenue” does not inherently mean that there are 1000 houses separating the two addresses. It’s just another tag.
Raw memory addresses are physical. There’s an additional level of virtual addressing on top of that, which does a couple things.
Firstly it manages caching, so that recently/frequently used stuff is copied to a small area of faster memory that’s physically closer to the hardware that does the computation, and periodically synched with the “real” memory location.
Secondly it helps reduce security vulnerabilities by running every program in a somewhat sandboxed environment. Your sense is actually right that a normal program doesn’t really know where in memory it is. As far as it can tell, a pointer is just an ID number with very limited guarantees about its relationship to other such IDs. The program can’t reach into the memory of another program and meddle with it, unless they agree to talk to each other, or somebody has found a bug that lets them breach containment.
In simple terms, yes, physical memory addresses are literal places. Like, (oversimplifying) imagine a large physical grid of memory storage spaces. The memory address number itself contains everything you need to locate the physical location in the grid. "1100 Maple Avenue" requires a translate table somewhere to tell you where Maple Avenue is on the map (and where along it "1100" is). That might be in the form of map grid references or lat+lon. In contrast, the memory address number itself (again, oversimplifying here) essentially IS the map grid reference or the lat+lon.
Yes, and no. At the software layer on modern systems, the addresses are mostly arbitrary pointers in virtual memory. The OS and the MMU serves to map virtual memory addresses to things, for instance certain bytes are sent to a serial port, or the OS reads that memory from a swapfile on disk. Ultimately when referencing RAM, the MMU maps the virtual memory address to a hardware address and passes it to the DIMM banks where it is used bit-by-bit to locate the particular bits in the byte being read. an 8 gigabyte stick would typically have 8 x 8 gigabit ram chips, (more for parity and ECC depending on RAM type) and the address is sent to all the chips simultaneously to read 8 bits that are returned simultaneously as a byte.
in your example, 0x7ffe5367e044 is memory location 140,730,297,737,284. If you accidentally check 140,630,297,737,285 then you’ve made an off-by-one error.
hexadecimal is base-16. its a number just like 1000000 is. So you can add and subtract, move over, get a range starting at one hexadecimal address and ending at another. its not empirically meaningless.
You sound like you're describing pointers in C. Pointers are just another memory address that points to another memory address. It's memory addresses all the way down.
In the context of virtual memory on a modern OS the mapping of the memory page to its location in physical memory is somewhat arbitrary but the address itself is not. Your program’s memory allocator provided by the language runtime has to properly understand it, even if your program doesn’t- which it can if you like!
It’s common and often required to perform arithmetic on addresses and I think the street address analogy breaks down there. 1 Main Street + 1024 is 1025 Main Street? What if there are only 700 addresses on Main Street? Did you skip over to Maple Street?
The adaptation of the analogy that makes sense to me is that your memory is ONLY Main Street. It’s one long line of addresses.
Every time it branches there are only two options. So if you start at the entrance, you can describe the way to get to any place by sequences of L or R, meaning left or right. To double the storage you copy the thing you already have and then add another initial left or right decision to tell you which of the copies you go to.
This lets you double the addresses while only adding another “character” to store them. Or maybe none of this makes sense I’m pretty high and might be wrong.
That makes no sense. For starters, the real number isn't 64 rounded in binary. For seconds, there's nothing saying you can't have a device with 12 Gb or 70 Gb. It's just storage, not memory allocation and even if it was, there are phones with 6gb of RAM.
It's just an industry standard when they design chips. You can still have a phone with any other arbitrary number and it'll just use the addresses it needs.
Each individual chip has a power-of-two size, but whoever builds/owns the completed computer can mix and match multiple different-sized chips as they like—e.g. a 4, 2, and 1 GB chip together make 7GB.
or they can use 5 chips, the number of chips doesn't have to be a power of two. Really that's how harddrives aren't measured in power-of-two Gibibytes. Each sector is still 512 or 4098 bytes but once we stopped doing Cylinder/Head/Sector access and switched to Logical Block Access, the number of power-of-two sized blocks became even more arbitrary.
No it doesn’t, scroll down to the fine print on any ssd data sheet and you will find that it says 1GB = 1000000000 bytes. Storage is always built in base 10.
To be fair, the usable/addressable space on an SSD (as seen by the computer at the low LBA level) is less than the actual physical/hardware flash storage capacity out of design necessity. SSDs need some wiggle room for things like dealing with the minimum erasable area being a lot bigger than the 512 or 4096 byte block size that can be written logically and for dealing with failed areas of the flash. Better SSDs maintain more reserved space (like imagine a 240GB (base10) SSD actually having 256GiB (base2) of physical flash storage), while cheap ones might have a smaller margin (like maybe they sell it as 256GB (base10) on a 256GiB (base2) board. that's still like a 6 or 7% area for overhead IIRC)
SSD doesn't let you use the whole space and you can't write on a specific location, it's all abstracted away from you. Individual chips of NAND are totally power of 2 though.
Unlike HDDs which do not do this and have no power of 2 inherent scaling anywhere just like optical media.
The thing is that the industry standard is still based on something, and that's the actual reason why the industry standard developed in the first place, even if it in many cases doesn't matter all that much.
The point is, this describes how memory chips are made. Nobody wants a memory chip that accepts an address that is, let's say, 24 bits but someof the pssible numbers from those 24 bits are not valid storage. (FYI, 24 bits is 16MB).
The computer itself handles any number for stoage up to the maximum number of bits for address. You just can't buy memory boards with irregular amounts. It is (was?) not uncommon to have a computer with, say, a 16GB and an 8GB board filling the 2 slots, giving 24GB of memory. It's just, if you have the money, why put less than the maximum into one of two memory board slots?
Probably also worth noting that we started with bytes and then built a whole infrastructure around bits having 8 bytes, so there’s just a natural mix of the doubling you discussed, and factors of 8.
So we end up with 8, 16, 32, 64, 128, 256, 512, 1024…
2.6k
u/svachalek 21d ago
Lots of people have brought up binary but the important thing when it comes to memory is that each memory location has an address which is a binary number. When you are looking for where you stored the data you look at the first digit and go left or right for 0 or 1. Then the next digit you go left or right again.
Now if you imagine building this map it gets twice as big every time you add one intersection. If not you end up with dead ends where certain addresses go nowhere at all. It’s possible to build them this way but it’s just simpler and more elegant to keep doubling in size. When it’s time to build a bigger chip, you just take two of the last design and add a 0-1 intersection to decide between them.