OK, enough just playing around with ChatGPT; let’s see if it can write some code:
Continue reading “ChatGPT Writes Decent Code For Binary to Decimal Conversion”
Binary Numbers, Binary Code, and Binary Logic
Articles About Binary Numbers As They Exist Outside of Computers
OK, enough just playing around with ChatGPT; let’s see if it can write some code:
Continue reading “ChatGPT Writes Decent Code For Binary to Decimal Conversion”
Continuing with my recent conversation with ChatGPT I thought I’d ask it if it could write haiku about binary numbers, like I have:
Nice, but I was looking for the 5/7/5 syllable format (this is 6/8/5), so I asked for that specifically:
I’ve previously written a Windows program (in C++) and an Android app (in Java) to turn my Fretlight guitar into a binary clock. I’ve now written a Python program to do the same, running under Raspbian Linux on a Raspberry Pi computer. I will show you the code and tell you how to run it.
Continue reading “My Fretlight Guitar Binary Clock: Raspberry Pi Edition”
With a little research and some USB tracing, I wrote a Windows program — and an Android app — that turns my Fretlight guitar into a BCD mode binary clock!
(Update: I now also have a Raspberry Pi version.)
I want to contribute to the Hour of Code event happening now during Computer Science Education Week.
I don’t write about computer programming, but I do write extensively about how computers work — in particular, about how they do arithmetic with binary numbers. For your “hour of code” I’d like to introduce you to binary numbers and binary addition. I’ve selected several of my articles for you to read, and I’ve written some exercises you can try on my online calculators.
Continue reading “Hour of Code: Binary Numbers and Binary Addition”
This is a companion article to “Number of Bits in a Decimal Integer”
If you have an integer expressed in decimal and want to know how many bits are required to express it in binary, you can perform a simple calculation. If you want to know how many bits are required to express a d-digit decimal integer in binary, you can perform other simple calculations for that.
What if you want to go in the opposite direction, that is, from binary to decimal? There are similar calculations for determining the number of decimal digits required for a specific binary integer or for a b-bit binary integer. I will show you these calculations, which are essentially the inverses of their decimal to binary counterparts.
Continue reading “Number of Decimal Digits In a Binary Integer”
Excluding 0 and 1, it takes more digits to express an integer in binary than in decimal. How many more? The commonly given answer is log2(10) ≈ 3.32 times as many. But this is misleading; the ratio actually depends on the specific integer. So where does ‘log2(10) bits per digit’ come from? It’s a theoretical limit, a value that’s approached only as integers grow large. I’ll show you how to derive it.
Every integer has an equivalent representation in decimal and binary. Except for 0 and 1, the binary representation of an integer has more digits than its decimal counterpart. To find the number of binary digits (bits) corresponding to any given decimal integer, you could convert the decimal number to binary and count the bits. For example, the two-digit decimal integer 29 converts to the five-digit binary integer 11101. But there’s a way to compute the number of bits directly, without the conversion.
Sometimes you want to know, not how many bits are required for a specific integer, but how many are required for a d-digit integer — a range of integers. A range of integers has a range of bit counts. For example, four-digit decimal integers require between 10 and 14 bits. For any d-digit range, you might want to know its minimum, maximum, or average number of bits. Those values can be computed directly as well.
I just noticed something cute: if you Google binary, Google returns its count of results in binary. Here’s a screenshot:
Continue reading “Googling ‘Binary’ Returns Count of Results In Binary”
In decimal, “0.9 repeating”, or 0.9, equals 1. In binary, a similar thing is true: “0.1 repeating”, or 0.1, equals 1. I’ll show you three ways to prove it, using the three bicimal to fraction conversion algorithms I described recently.
I’ve shown you two ways to convert a bicimal to a fraction: the subtraction method and the direct method. In this article, I will show you a third method — a common method I call the series method — that uses the formula for infinite geometric series to create the fraction.
Continue reading “Converting a Bicimal to a Fraction (Series Method)”
There are several ways to convert a repeating bicimal to a fraction. I’ve shown you the subtraction method; now I’ll show you the direct method, my name for the method that creates a fraction directly, using a numerator and denominator of well-known form.
Continue reading “Converting a Bicimal to a Fraction (Direct Method)”