DevTools Logo
All posts

Bits to Permissions: Floats, Huffman Codes, K-Maps and SemVer

September 5, 2026 · DevTools

binary
floating-point
compression
semver
linux

Some bugs live below your source code: a float that prints as 0.1 but stores something slightly different, a permission string that looks right but drops the setuid bit, two dependency ranges that silently admit nothing. This guide works through five tools that make those layers visible: the Bitwise & IEEE-754 Explorer, the Huffman Coding & Shannon-Fano Tree, the Karnaugh Map Solver, SemVer Range Intersection, and the Chmod Octal & Symbolic Matrix.

How IEEE-754 floats are actually stored

The explorer encodes a number with a real DataView (setFloat32/setFloat64) and splits the resulting bit string into sign, exponent, and mantissa: 1-8-23 for f32, 1-11-52 for f64. It reports the biased exponent value, the unbiased exponent (bias 127 for f32, 1023 for f64), and a classification of zero, subnormal, normal, infinity, or nan. For f32 it also shows the rounded-back value, which is why 0.1 reads as 0.100000001490116.

The same tool covers 32-bit integer logic: AND, OR, XOR, and NOT over >>> 0 unsigned values, plus shift32 and rotate32 (shifts masked with & 31), hex input like 0xFF, and zero-padded hex/binary formatting.

Optimal codes and minimal boolean expressions

Paste text into the coding tool and it builds both a Huffman tree (repeatedly merging the two lowest-frequency nodes, ties broken by smallest character) and a Shannon-Fano tree (splitting sorted symbols where |total − 2 × left| is minimal). Alongside the per-symbol codes it reports Shannon entropy, average code length, encoded bits versus the 8-bit-per-character baseline, and savings percent. A single-symbol input gets the code "0", and whitespace renders as , , and so spaces stay countable.

The Karnaugh solver handles 2, 3, or 4 variables with cells of 0, 1, or 2 (don't care). It enumerates every valid cube, keeps the prime implicants, then searches for the smallest cover — fewest groups, then fewest literals. You get SOP such as AB + C' and POS such as (A + B') · (C + D) together, each group listing covered minterms, bit pattern like 1-0-, and eliminated variables.

InputHuffman ideaK-map idea
aaaabbca gets the shortest codeones grouped in powers of two
Don't cares (2)n/amay be absorbed into cubes to grow groups
Outputentropy vs. average length gapSOP + POS expressions

Ranges, wildcards, and permission bits

The SemVer tool parses ^, ~, wildcards (1.x), hyphen ranges, comparators, and || unions, then intersects two or more ranges into a tight lower/upper bound. ^1.2.3 becomes >=1.2.3 <2.0.0 (and ^0.2.3 stays conservative at <0.3.0); prerelease versions only satisfy a set that names a prerelease on the same major.minor.patch. An empty result names its reason, e.g. "Ranges do not overlap".

^1.2.3  →  >=1.2.3, <2.0.0
~1.2.3  →  >=1.2.3, <1.3.0
1.2.x   →  >=1.2.0, <1.3.0

The chmod matrix converts both directions between 3–4 digit octal and 9-character symbolic strings. The leading digit packs setuid/setgid/sticky, rendered as s/S and t/T depending on the execute bit. It also applies symbolic expressions (u+x, go-w, a=rwx, conditional X) against a base mode and can print an ls -l style line.

Try Them