Binary Math Tricks: Shifting To Divide By Ten Ain’t Easy

On small CPUs, you often don’t have a multiply or divide instruction. Of course, good programmers know that shifting right and left will multiply or divide by a power of two. But there are always cases where you need to use something that isn’t a power of two. Sometimes you can work it out for multiplication.

For example, multiplying by 10 is common when dealing with conversion between binary and decimal. But since 10n is equal to 8n+2n, you can express that as a bunch of left shift three times to multiply by eight, adding that value to your original value shifted left once to multiply by two.

But division is a different problem. n/10 does not equal n/8-n/2 or anything else simple like that. The other day a friend showed me a very convoluted snippet of code on Stack Overflow by user [realtime] that divides a number by 10 and wanted to know how it worked. It is pretty straightforward if you just stick with the math and I’ll show you what I mean in this post. Turns out the post referenced the venerable Hacker’s Delight book, which has a wealth of little tricks like this.

Continue reading “Binary Math Tricks: Shifting To Divide By Ten Ain’t Easy”

A Beginner’s Guide To Lithium Rechargeable Batteries

Batteries were once heavy, awkward things, delivering only a limp amount of current for their size and weight. Thankfully, over time, technology has improved, and in 2020, we’re blessed with capable, high-power lithium polymer batteries that can provide all the power your mobile project could possibly need. There are some considerations one must make in their use however, so read on for a primer on how to properly use LiPos in your project!

So Many Types!

With the first commercial lithium-ion battery entering the market in 1991, the (nearly) 30 years since have seen rapid development. This has led to a proliferation of different technologies and types of battery, depending on construction and materials used. In order to treat your batteries properly, it’s important to know what you’ve got, so paying attention to this is critical. Continue reading “A Beginner’s Guide To Lithium Rechargeable Batteries”

Quantum Computing And The End Of Encryption

Quantum computers stand a good chance of changing the face computing, and that goes double for encryption. For encryption methods that rely on the fact that brute-forcing the key takes too long with classical computers, quantum computing seems like its logical nemesis.

For instance, the mathematical problem that lies at the heart of RSA and other public-key encryption schemes is factoring a product of two prime numbers. Searching for the right pair using classical methods takes approximately forever, but Shor’s algorithm can be used on a suitable quantum computer to do the required factorization of integers in almost no time.

When quantum computers become capable enough, the threat to a lot of our encrypted communication is a real one. If one can no longer rely on simply making the brute-forcing of a decryption computationally heavy, all of today’s public-key encryption algorithms are essentially useless. This is the doomsday scenario, but how close are we to this actually happening, and what can be done?

Continue reading “Quantum Computing And The End Of Encryption”

The Seedy World Of Message Serialization

Look, I’ve been there too. First the project just prints debug information for a human in nice descriptive strings that are easy to understand. Then some tool needs to log a sensor value so the simple debug messages gain structure. Now your debug messages {{look like : this}}. This is great until a second sensor is added that uses floats instead of ints. Now there are sprinklings of even more magic characters between the curly braces. A couple days later and things are starting to look Turing complete. At some point you look up and realize, “I need a messaging serialization strategy”. Well you’ve come to the right place! Continue reading “The Seedy World Of Message Serialization”

Bertha Benz Pushed The Automobile Toward Production

Who invented the automobile? The answer depends a little bit on your definition of the word. The first practical gas-powered carriage was built by Karl Benz, who later merged his company with Daimler Motor Group to form Mercedez-Benz.

Karl Benz was a design visionary whose first fascinations were with locomotives and bicycles. His 1886 Benz Patent Motorwagen was the first automobile to generate its own power, which was made with a two-stroke engine and transmitted to the rear axle by a pair of chains. He didn’t think it was ready for the road, and he was mostly right.

Bertha Benz, Karl’s wife and business partner, believed in her husband’s invention. She had been there since the beginning, and provided much of the funding for it along the way. If she hadn’t taken it out for a secret, illegal joyride, the Motorwagen may have never left the garage.

Continue reading “Bertha Benz Pushed The Automobile Toward Production”

Teardown: The Writer Word Processor

For modern students, the spiral notebook has given way to the laptop and the pocket calculator has been supplanted by the smart phone. We’re not just talking about high school and college, either. Today, the education of even grade school children is intrinsically linked with technology. While some might question the wisdom of moving away from the pencil and pad at such a young age, there’s little question that all the kids stuck at home right now due to COVID-19 would have had a much harder time transitioning to remote learning otherwise.

But that certainly wasn’t the case when Advanced Keyboard Technologies released the Writer in 2003. Back then, five years before the first netbooks hit the market, you’d be hard pressed to find a laptop cheap enough to give to a grade school student. In comparison, these small electronic word processors could be purchased for as little as $150. Not only was the initial price low, but the maintenance costs were almost negligible. They ran for hundreds of hours on a standard AA batteries, and didn’t require schools to have any IT staff to manage them. Sure they couldn’t get on the Internet or even run any software, but they would give students a chance to hone their keyboarding skills. Continue reading “Teardown: The Writer Word Processor”

Vernier Calipers And Micrometer Screw Gauges, Measuring Without Compromise

I needed a temperature controller module recently, so off I went to Banggood to order one. As one does I found myself browsing, one thing led to another, and I bought a micrometer screw gauge. While micrometers are pretty expensive devices, reflecting their high precision engineering and construction, this micrometer cost me only about £8, or just under $10, definitely in the spirit of our long-running series of reviewing very cheap tools in search of a diamond in the rough. But perhaps more importantly, this is also the cue for an examination of high precision dimensional measurement. So I’ve assembled a collection of micrometers and vernier calipers of varying quality, and it’s time to dive in and measure some very small things.

Some of you will be metrology enthusiasts with an array of the finest devices available, but I am guessing that many of you will not. The ubiquitous precision measurement device in our community appears to be the digital caliper, a sliding clamp with an LCD display, an instrument that can be had in its most basic form for a very small outlay indeed. For the purposes of this piece though we’re not looking at digital devices but their analogue precursors. If you want a feel for metrology and you’d like some of those heritage tools that parents pass onto their kids then it’s time to learn something about the vernier caliper and the micrometer. Continue reading “Vernier Calipers And Micrometer Screw Gauges, Measuring Without Compromise”