4 ms·
Back in my day... probably not technically a lost art, but an interesting lesson in math. I remember I was in computer science class. I was 17 years old. And
by mattbgates 3y ago
Back in my day... probably not technically a lost art, but an interesting lesson in math.
I remember I was in computer science class. I was 17 years old.
And the teacher taught us how to read binary and how to calculate it. He said binary was math which is a universal language that even aliens could understand and would allow us to communicate though we'd still run into the struggle of converting that binary to actual meanings, such as converting binary to English or vice versa.
We often don't think about it, but our programming technology is based on binary calculations.
I'd put the Conversion to Binary or from Binary in the lost arts category because I highly doubt it is ever taught, not even in computer science classes nowadays because its just slow and boring to do the conversions.
But if you do think about it, he wasn't wrong.
For those who are curious about it:
Converting binary to English or math involves interpreting the binary representation of numbers or characters into their corresponding decimal values or ASCII representations. Here's how you can do it:
Binary to Decimal (Math):
Each digit in a binary number represents a power of 2. To convert binary to decimal, start from the rightmost digit and multiply each digit by 2 raised to its position, then sum up the results.
Example: Convert binary 1101 to decimal.
1 * 2^3 + 1 * 2^2 + 0 * 2^1 + 1 * 2^0 = 8 + 4 + 0 + 1 = 13
Binary to ASCII (English):
ASCII (American Standard Code for Information Interchange) is a character encoding standard where each character is represented by a unique numeric value. In ASCII, each character is assigned a decimal value, which can be converted from binary.
Example: Convert binary 01001000 01100101 01101100 01101100 01101111 to ASCII (which represents the word "Hello").
01001000 -> 72 (H)
01100101 -> 101 (e)
01101100 -> 108 (l)
01101100 -> 108 (l)
01101111 -> 111 (o)
So, to convert binary to English or math, follow these steps:
For English (ASCII characters):
Divide the binary into groups of 8 bits (1 byte).
Convert each group of 8 bits to decimal.
Find the ASCII character associated with the decimal value.
For Math (Decimal):
Write down the binary number.
Multiply each binary digit by 2 raised to its position (starting from the rightmost position).
Sum up the results to get the decimal equivalent.
Keep in mind that this process is straightforward for numbers and ASCII characters, but other types of binary data (like images or files) may require different methods to interpret.
- xp84 3y agoTangentially related: storing a bitmask in your database (as a single 32-bit value) to track many flags, and using bitwise math to manipulate/interpret it. Much more space efficient than what everyone would do now (a bunch of tinyints, enums, or booleans) but obviously you’d be rightly fired out of a cannon now for introducing something so difficult to grasp for young devs, just to save “cheap” memory and storage.
- warrenm 3y agoBit masks are cool They are also very fragile Far better to have some maintainable and extendable (what happens when you exceed 32 binary flags?) than being overly clever for the sake of saving a couple bytes of storage
- xp84 3y agoNo dispute there, it would be silly now, I just think it was kind of cool how programmers used to understand how binary worked, and appreciate that it was worth it at one point to use 1 actual bit to store a true/false value.
- dekhn 3y agoI have a few simple bit questions in my coding interviews and most programmers simply don't know how to set a bit in a byte (or word), rotate bits in a byte (or word), or what endian is.
- frfl 3y agoIn the 2010s binary was taught in high school intro to CS and in university CS classes. I don't know about bootcamps though, I doubt it is taught there. What isn't really taught is binary representations and what things look like in memory. I think there was one class in university that covered it, but just briefly.
- rthomas6 3y agoBinary is used often by embedded programming/FPGA dev types. I use binary and hexadecimal every day.