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 ...

Keep That Old Printer, or, New Printers Stink

Old laser printers have some notable advantages over many newer printers. An old laser can be found for little money. You can easily find great working printers on Craig's List for under $40. My old-school HP LaserJet 5L - still works like a champ! The inexpensive toner cartridges for these printers can often be found on Amazon for under $20 each. And each cartridge, typically rated for several thousand pages, can last five times longer than many more expensive inkjet cartridges. And these old printers are solid. Many were designed last for years in high volume situations. And they were designed to be maintained, instead of thrown away. My laser is nearly 15 years old and it keeps on ticking. Keeping it Modern Buying a good old fashion laser jet for under $40 is easy. But it likely has an old-fashion Parallel interface on it - meaning that your computer can't even use it. What to do? My answer was to buy an Epson Net C823781 Print Server . It isn't the latest device...

Repairing a Crate TX15 Taxi amplifier battery

A friend gave me a Crate battery guitar amp that he used for busking. It is a nice 15 watt amp with an internal battery. Sadly it died, and its custom power adapter was misplaced. After several years the battery will fail, and it requires a functioning battery to work at all. Happily, new batteries are inexpensive, readily available, and easy to install. Obtaining a replacement battery for the TX15 The original battery was a 4+ pound, sealed lead battery. Any replacement battery should closely follow the specs of the original. I bought this MightyMax Battery on Amazon , which is a perfect replacement. There are many batteries that conform to the needs of the TX15, and they can be found at local hardware stores as they are commonly used in lots of equipment. It pays to look locally if you need something faster than Amazon.  The battery specs are as follows: 12 Volt, 7.2 Ah lead battery (mine was marked 1272). Length: 5.94" (151 mm)  Width: 2.56" (65 mm) Height: 3.94" (100...

Installing the Eve Smart MotionBlind Upgrade with my Large Roller Shade

I have a large window in the front of my house and a roller shade was just the right window treatment for it.  But I also wanted to automate it. My MotionBlind Upgrade kit and my new roller shade I looked around to buy something that I was comfortable with, but simple non-automated roller blinds can be expensive, especially when they're larger than 6 ft x 6 ft.   This is disappointing, as a roller blind is just a tube with a small amount of synthetic cloth but can easily cost hundreds of dollars. Plus, since I wanted a smarthome blind, we're talking $500 or more from the "service oriented shops". I'm a tech guy.  I think can do better. After thinking about DIY and creative solutions, I decided to try out the Eve MotionBlinds Upgrade (MBU) kit.  This kit transforms an ordinary roller blind into a smart blind.  The MotionBlinds mechanism is basically consists of a small motor and battery in a long metal tube.  This motor tube slides into a roller blind ...

The Yamaha DD-65 and YDD-60 Digital Drums

Almost everyone I know who is into drums should get their hands on the Yamaha DD65 . It's a low cost, fun little kit that you can throw in your car to jam with your buddies. It's a lot easier than throwing your gear in your Subaru. The DD-65, also known as the YDD-60. Eight pads in a pretty package. I've owned the older, venerable DD-55 for about five years. The DD-55 is the ancestor of the newer DD-65, and is an evolution of the DD-50, which was first released some time in the mid 1990s. I just put my DD-55 on this light snare drum stand it's ready for some jamming. The classic DD-55. Seven pads of rockin' fun, since about 2001. Yes, everyone will tell you that the DD-55 isn't actually a real drum kit. No kidding. However, a skilled drummer can get some great sound out of this little box, and you can definitely keep the band together with it. Plus, it's perfect for apartment living.

Fix a bad MacBook trackpad

The Problem: A Poorly-Behaving Trackpad Button MacBook trackpads buttons are going bad. Happily, there is a quick and technically-simple fix that may work for many MacBook owners with a misbehaving trackpad. A few months ago I started to notice that my trackpad was operating in a funky manner. The trackpad button had lost its solid click and turned mushy. As I typed the trackpad button would mistakenly register clicks, and the cursor would jump all over the place; The cursor would jump around and my words would end up jumbled. Or a button press wouldn't register at all, and I'd end up trying to smash down of the button with no response. It was the worst experience I’ve ever had with a keyboard and mouse. I tried every technique I could find on the web to try to fix my bad trackpad button – from sliding paper through the gap around button, to MacBook disassembly and vacuuming everything. Nothing made it better. My MacBook was fairly unusable, and getting worse. Af...

Other Posts

Show more