Advertisement
Data Processing

The Paired Digit: When a Colour's Short Name Exists and When It Cannot

On a Monday morning a design team exports the same palette from two tools and runs its usual merge. The report comes back claiming that most of the co...

On a Monday morning a design team exports the same palette from two tools and runs its usual merge. The report comes back claiming that most of the colours are new. Swatches the team recognises on sight are listed as unmatched, as if the second tool had invented a fresh palette overnight. Nobody recoloured anything. The two exports simply wrote the same colours in different forms: one in full six-digit hex, the other mixing a three-digit shorthand, capital letters, and decimal rgb() values. The merge believed the strings instead of the colours, and the strings disagreed. This article follows that symptom through its causes to the parse that reunites all 300 colours.

What The Paired Digit means

The Paired Digit is the rule that the three-digit colour shorthand works only when every channel's two hex digits are the same digit doubled, AA, BB, CC, so the shorthand exists for a colour exactly when its digits come in pairs. The nearest prior concept is The Base Sixteen, a prior concept about counting and writing values in base sixteen. The Base Sixteen is about the base a number is written in, and it applies to every value. The Paired Digit stays inside hexadecimal and is about a compression that only exists when each byte's two digits match. That difference is practical: a team can convert any colour between bases, but it can only shorten a colour when the pairs are doubled.

The 300 Colour Symptom In 1 Failed Palette Merge

The symptom, measured, looks like this. Two inventories hold the same 300 distinct colours. Inventory A stores every colour as #RRGGBB in lowercase, the full six-digit form. Inventory B stores the same 300 colours in four forms, in four blocks of 75: the #RGB shorthand, which only the doubled-digit colours can carry; the canonical lowercase form; canonical uppercase; and rgb(r, g, b) in decimal. Of the 300 colours, 75 have all three channels doubled, and 225 are general colours with unpaired digits. When the merge compares strings exactly, it reunites only 80 of the 300 and reports 220 colours as new: a palette that looks mostly new while being entirely the same palette.

The Seed 42 Measurement Behind The 300 Colours

The numbers here were produced by a purpose-built synthetic run for this batch, and they describe that run only; no commercial product was tested. Working from seed 42 with nothing beyond the standard library, the run fixed 300 colours whose true 24-bit values were recorded before any spelling was generated, 75 built from doubled digits and 225 general colours. Each colour was then written twice, once in the canonical lowercase six-digit form and once in one of four surface spellings: shorthand, canonical lowercase, canonical uppercase, or decimal rgb(). The run applied its matching strategies one stage at a time and tallied, at every stage, how many colours were reunited and how many were falsely merged. The script and the result JSON ship with this batch as evidence, so the counts can be regenerated rather than trusted.

The 3 Possible Causes Of 220 Unmatched Colours, In Probability Order

When a palette merge undercounts, three causes explain nearly every case, and they should be checked in this order. The most probable cause is case: one export writes lowercase hex and the other writes uppercase, so identical digits fail an exact comparison purely because a became A. The second cause is the shorthand form: an export that can shorten a colour does so, writing #ABC where the other export holds #AABBCC, two strings that share almost nothing yet name one colour. The third cause is the rgb() decimal form: a colour arrives as rgb(170, 187, 204), with no hex digits visible at all. The order matters because the fixes differ in reach: case is fixed by folding letters, the shorthand needs expansion, and the decimal form needs conversion.

Ruling Out The 3 Causes Of The 300 Colour Mismatch

Ruling the causes out in turn means running the stages and watching the counts. Exact string matching reunites 80 of 300, with 0 false merges. That 80 is the 75 canonical rows, plus 5 uppercase rows whose digits were all numeric, so case changed nothing and they matched early. The case cause is then tested directly: fold case and compare again. The count rises to 150 of 300, with 0 false merges, because both canonical blocks are now reunited. Case therefore explains 70 of the missing colours, and nothing else: the shorthand and rgb() blocks are untouched by folding letters, because their difference is not letter case. Both remaining causes are confirmed by form: the shorthand block holds exactly the 75 doubled-digit colours, written with three digits instead of six, and the rgb() block holds 75 colours written as decimal triples. A fuller parse is required.

Stage or Inventory B form for 300 coloursRows or matchedFalse merges
Exact string match80 matched0
Casefold only150 matched0
Full parse, expand shorthand and parse rgb()300 matched0
Shorthand block in Inventory B75 rows—
Canonical lowercase block in Inventory B75 rows—
Canonical uppercase block in Inventory B75 rows—
rgb() decimal block in Inventory B75 rows—

Confirming The Fix: The Full Parse Of #AABBCC Reaching 300

The fix is a full parse: read every spelling back to the colour it names, then compare colours instead of strings. The parser folds case, expands the shorthand by doubling each of its three digits, and converts rgb() decimal triples into hex. Run over both inventories, it reunites 300 of 300 colours, with 0 false merges. The colour #AABBCC shows all three routes landing on one colour. In shorthand it is stored as #ABC, and the expansion doubles each digit in turn: A becomes AA, B becomes BB, and C becomes CC, rebuilding #AABBCC exactly. In decimal form it is stored as rgb(170, 187, 204), and each decimal value converts back to a pair of hex digits: 170 equals AA, 187 equals BB, and 204 equals CC. Three spellings, three different strings, one colour. A checksum guards the whole result: the sum of the 24-bit colour values across all 300 colours is 2,455,291,682, and any merge claiming the same 300 colours must reproduce that total.

The 6 Field Record Template For 1 Unmatched Colour

When a colour still fails to match, log it before fixing it, so the failure stays diagnosable. The record template has six fields. First, the colour as written in Inventory A, copied exactly, including its case. Second, the colour as written in Inventory B, copied exactly, including any shorthand or rgb() form. Third, the form of each spelling: shorthand, canonical lowercase, canonical uppercase, or rgb() decimal. Fourth, the stage at which the pair failed: exact, casefold, or full parse. Fifth, the parsed 24-bit value of each spelling, so a reader can see whether the colours agree even when the strings do not. Sixth, the cause ruled in or out: case, shorthand, or decimal form. Such records show which cause dominates a real palette.

The Paired Digit: When a Colour's Short Name Exists and When It Cannot

Questions on the paired digit, answered

Q: Why can only 75 of the 300 colours use the shorthand? A: The shorthand keeps one digit per channel, so it is lossless only when each channel's two digits are the same digit doubled. Only 75 of the 300 colours qualify; the other 225 would lose information.

Q: Why did exact matching find 80 colours rather than 75? A: The canonical block gives 75 matches. Five uppercase rows also matched, because their hex digits were all numeric, so their two cases are the same string.

Q: Why does casefolding stop at 150 of 300? A: Casefolding reunites the two canonical blocks, 75 lowercase and 75 uppercase rows. The shorthand and rgb() blocks differ in form, not case, so folding letters cannot reach them.

Q: How does #ABC become the same colour as rgb(170, 187, 204)? A: Expanding #ABC by doubling each digit gives #AABBCC. Converting the decimals gives 170 equals AA, 187 equals BB, and 204 equals CC: also #AABBCC.

Q: Did the full parse merge any 2 different colours by mistake? A: No. The full parse reached 300 of 300 with 0 false merges, and the checksum of 2,455,291,682 confirms the pairings.

The 1 Next Action For The Next 300 Colour Merge

When a palette merge undercounts, the next action is singular: stop comparing strings and parse every spelling back to its 24-bit colour value before comparing anything. Run that parse on the unmatched rows first, fold case inside it, expand any shorthand by doubling, convert any rgb() triple from decimal, and only then recount. In the measured run that single change moved the result from 80 matched to 300 matched, with 0 false merges: any colour still unmatched after a full parse is a genuine difference, not a disguised spelling.

Sources

> Source: SmartDataAI batch 23 measurement, group AN2 (evidence/sd_batch23_measurements.py and evidence/sd_batch23_results.json, run 2026-11-26).

Know someone who needs this? Share it.

Advertisement