Learn how binary encoding works (it’s more fun and useful than you think)

Human language encodes ideas

Computer encodings map data onto binary

What’s binary?

  • A tally of how many unique data values you’re going to encode.
  • Enough bits to have at least that many unique binary sequences.
  • For each unique data value, a way to reliably find a unique binary sequence to map it to.

Example encodings

Booleans

Integers

Bitfields

  • Can read posts (Bin 001, Dec 1)
  • Can edit posts (Bin 010, Dec 2)
  • Can create posts (Bin 100, Dec 4)

Text

Displaying binary: Hexadecimal and Base64

“Types” inform encoding

Truthiness, falsiness, and fuzzy types

  • In PHP, an empty array [] is falsey.
  • In GameMaker Studio 2 (GMS2, a program for making video games) any number less than 0.5 is falsey.
  • In JavaScript, NaN==false yields false (NaN means "Not a Number"), but casting it to a boolean does yield false, and it's also treated as false in if statements. So NaN is both falsey and not falsey, depending on context.
  • In JavaScript, using a bitwise operator on a number (which is likely a 64-bit float) first converts it into a 32-bit integer.
  • In JavaScript, 10+"10" is "1010", while 10*"10" is 100.
  • In Python 2.X, 3/2=1 but 3.0/2=1.5, while in Python 3.X both are 1.5.

Metadata and inference

  1. Data encodings are inventions, and you can encode things however you want to.
  2. You must know how something was encoded to be able to interpret it.

Bespoke encodings

Encoding is worth thinking about

--

--

--

CTO and Fullstack Webdev at Butterscotch Shenanigans

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Version Control with RStudio

Predicting Systemic Crisis in Africa

Correlation and causation

Change detection with Raster Vision

Hands on Churn Prediction with R and comparison of Different Models for Churn Prediction

Data Collection: Methods, Definition, Types, and Tools

A Data Science Journey

Data Poverty amid Abundance: Challenges for the Global South

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adam Coster

Adam Coster

CTO and Fullstack Webdev at Butterscotch Shenanigans

More from Medium

My Data Science Journey…So Far

Sky’s The Limit

Basics of Statistics : Part 1

How “love” can make you a machine learning engineer.

How “love” can make you a machine learning engineer.

Machine Learning use cases in E-Learning