But if you're curious, you can read our whole big O explainer here. Or linear means the time or space grows proportionally as the dataset grows. Or constant means the time or space stays about the same even as the dataset gets bigger and bigger. It's a tool we use for talking about how much time an algorithm takes to run or how much space a data structure takes up in RAM. If we have a 64-bit fixed-length integer, it doesn't matter if that integer is 0 or 193,457-it still takes up the same amount of space in RAM: 64 bits. Variable-size numbers exist, but they're only used in special cases. It's usually safe to assume an integer is fixed-width unless you're told otherwise. Most integers are fixed-width or fixed-length, which means the number of bits they take up doesn't change. YouTube famously ran into trouble when the Gangnam Style video hit over 2^ views, forcing them to upgrade their view counts from 32-bit to 64-bit signed integers. When is 32 bits not enough? When you're counting views on a viral video. Have you ever noticed how in some languages ( like Java and C++) sometimes numbers are Integers and sometimes they're Longs? The difference is the number of bits (in Java, Integers are 32 bits and Longs are 64).Įver created a table in SQL? When you specify that a column will hold integers, you have to specify how many bytes: 1 byte ( tinyint), 2 bytes ( smallint), 4 bytes ( int), or 8 bytes ( bigint). "How come I've never had to think about how many bits my integers are?" Maybe you have but just didn't know it. The processor has a cache where it stores a copy Speed boost when reading memory addresses that're close to each Memory addresses quickly, programs tend to access memory Reading bytes that are far apart takes longer because you have to wait for the head to physically move along the disk.Įven though the memory controller can jump between far-apart Instead, there's a reader-called a head-that moves along the surface of a spinning storage disk (like the needle on a record player). Spinning hard drives don't have this "random access" superpower, because there's no direct connection to each byte on the disk. That's why we call it Random Access Memory (RAM)-we can Access the bits at any Random address in Memory right away. It means we can access address 0 and then immediately access address 918,873 without having to "climb down" our massive bookshelf of RAM.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |