'''Unary coding''',<ref group="nb" name="NB1"/> or the [[unary numeral system]] and also sometimes called '''thermometer code''', is an [[entropy encoding]] that represents a [[natural number]], ''n'', with ''n'' ones followed by a zero (if ''natural number'' is understood as ''non-negative integer'') or with ''n'' − 1 ones followed by a zero (if ''natural number'' is understood as ''strictly positive integer''). For example 5 is represented as 111110 or 11110. Some representations use ''n'' or ''n'' − 1 zeros followed by a one. The ones and zeros are interchangeable [[without loss of generality]]. Unary coding is both a [[prefix-free code]] and a [[self-synchronizing code]].
{| class="wikitable"
! n (non-negative) !! n (strictly positive) !! Unary code !! Alternative
Line 93:
==Notes==
{{Reflist|group="nb"|refs=
<ref group="nb" name="NB1">The aquivalentequivalent to the term "unary coding" in German scientific literature is "{{lang|de|BCD-Zählcode}}", which would translate into "[[Binary coded decimal]] counting code". This must not be confused with the similar German term "{{lang|de|BCD-Code}}" translating to [[BCD code]] in English.</ref>