Skip to main content

On Kilobytes, Megabytes, and other computer-centric factors

I started programming way back. In those olden days I was working close to the hardware - on machine language code (assembly languages). Bits were important: shift left, shift right, AND/OR/XOR. And memory pages were important too: fitting an important routine within a 256 byte page of RAM could really help performance.

Today, life is different. Instead of choosing a memory address, Programmers allocate objects. If a programmer is storing a boolean, a boolean object is created. Who knows how that's represented under the hood, but it certainly isn't represented in one bit of RAM. Most programmers don't even use the bit-wise operators offered through the programming languages given to them. Sure, some do. But most do not.

And so now we get into our prefixes: kilo, mega, giga, terra, and peta (and beyond, I suppose)

Many programmers still want these prefixes to be based on powers of 2. One kilobyte is 1024 bytes (2^10). One megabyte is 1024*1024 bytes (2^20). Etc. It was a useful system up until the early 1980s, but today it serves no purpose. Why is a kilobyte 2^10? Because the number, when converted to decimal, is the power-of-two number that is closest to 1,000. 2^11 and 2^9 simply aren't as close to 1000 as 2^10.

Anyhow, all this makes some (but not much) sense in terms of addressing RAM. Then these same people wanted everything else related to computing to work the same way.

Disk Storage

So the programmers decided that since physical RAM layout was important, and that it was good to have a funny math for it, that others should follow their methods. The programmers wanted disk drives to follow the same memory conventions. At first there was some practicality to this: programmers wrote code to stick pages of RAM onto disks in what they called "disk sectors". This was primarily done because it was very easy to treat a page of RAM (perhaps 2^8 bytes) as a body of work. This was key because performance ruled the day with 1 MHz computers. (By the way, the M in MHz means exactly "1,000,000").

But over time the disk drive guys lost interest. Sectors were a false abstraction, and under the hood of the drive sectors changed size to pack in more bytes, and low-level ECC and other techniques made it pointless. Furthermore, programmers were no longer dumping pages of RAM to disk, they just wanted to store files in a file system.

And so the drive guys started to sell disks using normal base-10 units. 100 MB drive means 100 Million Bytes. This was convenient to a lot of programmers because most left base-2 mathematics behind when higher level languages became practical. Before long, if a programmer said that there were 1K of rows in a database, they meant a normal thousand and not 1,024. 

That was the start of the first war. Programmers screamed at the drive guys for abandoning their "base 2" convention. Some programmers still wanted 1 MB of disk storage to mean 1024 *1024. But why? Programmers were no longer worrying about pages of RAM and sector sizes. Those same programmers also complained when they got less storage than on the box due to the overhead of things like the realities of how a file system works. And those same programmers are creating substantial "objects" to store a 3 character string. Talk about babies, they couldn't even appreciate a file system. They just liked their silly "my way or it is wrong" math despite the fact that their way no longer had a purpose.

Let me give you a practical example: Let's say you are dumping 1 billion records onto a disk. Each record is 40 bytes long. Quick, do you have enough room if you have 38.1 GB free? WHO KNOWS! Because bonehead holier-than-thou programmers that never shifted any register on any CPU wanted to confuse everyone.

Networking

Throughout all this the network guys were having none of it. They did things in bits per second. Bytes? No way! "Byte" was an ambigulously-sized number of bits, so they smartly renamed a collection of 8 bits an "octet". Kilo? To a network guy, that meant 1000. Nothing else. Mega? 1,000,000. 100 Megabits per second meant 100,000,000 bits in one second. And it still does to a network guy.

But then the uncultured programmers got in there using their personal ideals and wrote some networking software using their own rules and confused everyone. They started to apply their way to other realms for NO REASON.

What does 100 MB/second mean?

  • Normal Person: 100,000,000 bytes in one second (100 * 1,000,000)
  • Networking Person: 100,000,000 bytes in one second (100 * 1,000,000)
  • Programmer:
    • Normal: 100,000,000 bytes in one second (100 * 1,000,000)
    • Stupid: 104,857,600 bytes in one second (100 * (1024*1024))
    • Very Stupid: 102,400,000 bytes in one second (100 * (1024*1000))

Unfortunately, many programmers have fallen into the "Stupid" trap. Or worse.

These same annoying programmers no longer use the bin/oct/hex functions of their HP16C. In fact, I'd say they most wouldn't be able to use an HP16C to add two hexadecimal numbers together.

Conclusion

It's time to give up the fully obsolete base-2 notion of kilo, mega, and giga. If you really love powers of two, use them explicitly like a REAL tech expert would. My laptop has 2^33 addresses of active RAM. And now how many 2^8 byte pages of RAM fit into that address space? Comment with your simple assembly language program that calculates this number (any architecture).


Popular posts from this blog

Fixing a SodaStream Jet, part 1: Disassembly Guide

I've had my SodaStream Jet for years, and once in a while something has gone wrong. Disassembly is the first step to repair.  Start with this article to see how to disassemble the SodaStream, and then once you have that down, scroll through my other articles to see how I repaired specfic SodaStream problems. SodaStream Jet Disassembly Guide Tools Required Flat head screwdriver Phillips head screwdriver 1. Remove the Carbonator.  Duh. 2. Remove the black panel lever The front big black tilt lever needs to be removed first. Removing this panel is tricky, but it isn't impossible. Looking up at the bottom of the black panel, there are two tabs, one on the left and one on the right. These tabs fully secure the panel in place. The trick is to use a flat-head screwdriver under the plastic to gently lever the tabs out of the way.  Note in the pictures how I approach these tabs with my screwdriver.  I usually release the left side first, and then I release ...

Fixing my Wahl 9918 Groomsman Beard and Mustache Trimmer

Not everyone would bother repairing a $25 beard trimmer, but why not fix something for under $5 instead of spending another $25? My  Wahl 9918 Groomsman Beard and Mustache Trimmer  has admirably performed its beauty duty for many years, but the time came when the battery just wasn't holding a charge any more.  Most people would just put the trimmer in the trash and buy a new one, but I figured I could repair my otherwise excellent Wahl and save some money. In fact, even high priced trimmer and rotary shaver brands, like Norelco and Remington, can be easily repaired using a process similar to the one I used to fix my Wahl.  Read on to find out how. I opened up the Wahl by popping off the black plastic faceplate with a tiny flathead screwdriver, which revealed two screws.  By removing the two screws I was able to easily open up the unit, revealing the guts of the device. Backplate off, Revealing the screws The internals are rather simple: a motor, a...

Macintosh: Upgrading an eMac

It's been a long time since I wrote this article, but the fact remains: The good old eMac can still be useful if you take the simple steps to keep it as good as it can be.  All can run Tiger, and most can run Leopard - great operating systems for their day with a bit of useful life.  This article describes the procedure I used to upgrade my old eMac, including: Replacing the internal hard disk with a large capacity drive. Increasing the memory for performance Upgrading the operating system Here I'm upgrading a 700 MHz eMac, but the procedure and tasks for upgrading other eMac models should be almost identical. Upgrading versus Replacing My sister's eMac is of the 700 mhz variety, with 256 MB of memory. The machine seemed to be getting "slower", and the original 40 GB disk was becoming jammed packed with photos and iTunes, and within a few months she'd be out of disk space. There were two options to address the problems: upgrade the eMac, or go o...

Porsche Key Remote Battery Repair Video How-To

We now live in the age where part of your life is spending time and money maintaining and repairing things like your car keys . My Porsche's remote key was getting weaker and weaker, until one day it stopped operating altogether. Keyless remote without the remoteness. Not so good. I was a bit fearful spending a sizable chunk of my time and money at the dealership to have such a small problem addressed, and so I decided that I would try to replace the battery myself. Items required A clear work surface A small flat blade screw driver. A quality lithium CR-2032 Battery, available here. Procedure The following video shows how I successfully opened up the key without breaking it, and replaced the alarm remote battery. In short, from the vantage point of the key's steel part facing away and the buttons facing up: I take a small screwdriver and press on the little plastic tab on the left side.  At the same time I use my fingers to start to pull the two halves apart.  From th...

Trendnet TEW-652BRP and DD-WRT Success!

I recently visited my dad while on a business trip when I coincidentally discovered that DD-WRT is now available for his TEW-652. The TEW-652BRP has been a great router for my father, but it isn't what I'd call "feature rich". An upgrade to DD-WRT is a big bonus. I live 2500 miles away from my non-technical father, and so a well-specified router that helps me manage his network remotely is important to both of us. This article will explain what I did to finally get DD-WRT working on my TEW-652BRP v1.0R. About the TEW-652brp It's a nice looking little black 802.11n, 2.5 GHz router. It was amazingly inexpensive (usually way under $30), and  the TEW-652brp is available through Amazon. Mine is a version 1.0R, you'll likely want the same version. Out of the box, it works quite well - it has been stable, and I was fairly happy with the stock firmware. But it was short on features - I like having VPN, SSH, and flexible DHCP services on the home netwo...

Excellent DD-WRT Router for Me: Netgear WNDR3400 / N600

My WiFi performance was suffering, and so I decided to do something about it and upgrade my router. When I say my WiFi performance was suffering, I really mean it:  I live in a large high-rise apartment building and there are 100+ WiFi access points visible from my home office.  All of the contentious traffic was severely curtailing my WiFi reliability.  I was lucky to get 1 Mbit/second throughput.  Sometimes I was lucky to stay connected even with my WiFi router in the same room. I decided it was time to go for 5 GHz, which is a WiFi band which is used less frequently and which has a tougher time traversing walls.  And of course I wanted DD-WRT support.  The set of features I was looking for included: Trouble-free DD-WRT support 5 GHz 802.11n Support Simultaneous dual band capability Inexpensive.  Maybe even cheap.  For me this means under $50.  Under $35 is even better! It sounds like an easy task to bring all this together: A...

Other Posts

Show more