This page looks best with JavaScript enabled

Converting an Integer to a Bit Array - Lets Make a Binary Clock - Part 3

 ·   ·  ☕ 1 min read

Time to get back to our binary clock. In this episode we’re going to be looking into some core level computer science stuff: how to convert an decimal integer value into it’s binary component parts.To do this we’re going to be creating a custom class that can convert any integer into a fixed length bit array. Then we’re going to be binding that value to our already created user control in our app so that we can represent the binary values visually.

It’s simple, yet the results are key to the success of our app!

Our Integer to Boolean Array converter iterates over a string using binary operations to calculate the bit at a specific place. Then each bit can be stored into an array for use later on. The actual code required to do this is fairly simple with the exclusion of the binary operations which complicate things a bit.

Still, things go mostly successfully and we’ll have some time to cover how binary works in comparison to decimal data as well as how bit shifts work and more.

Want to see the code? It’s open source and available on GitHub! https://github.com/WorldOfZero/BinaryClock


Sam Wronski
WRITTEN BY
Sam Wronski
Maker of things and professional software engineer. Lets make something awesome together!