Unary coding: Difference between revisions

Content deleted Content added
TXiKiBoT (talk | contribs)
m robot Adding: fr:Codage unaire
Arkanosis (talk | contribs)
Depending on how we interpret ''natural number'', interpretation of unary coding may differ
Line 1:
'''Unary coding''' 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.
 
<table border="1" cellpadding="2">
<tr><th>n (non-negative)<th>n (strictly positive)<th>Unary code<th>Alternative
<tr><td>10<td>1<td>0<td>1
<tr><td>21<td>012<td>10<td>01
<tr><td>32<td>0013<td>110<td>001
<tr><td>43<td>00014<td>1110<td>0001
<tr><td>54<td>000015<td>11110<td>00001
<tr><td>65<td>0000016<td>111110<td>000001
<tr><td>76<td>00000017<td>1111110<td>0000001
<tr><td>87<td>000000018<td>11111110<td>00000001
<tr><td>98<td>0000000019<td>111111110<td>000000001
<tr><td>109<td>000000000110<td>111111110<td>0000000001
</table>