Golomb coding: Difference between revisions

Content deleted Content added
m Example: fmt.
Line 65:
== Example ==
 
Set {{math|''M'' {{=}} 10}}. Thus <math>b = \lfloor\log_2(10)\rfloor = 3</math>. The cutoff is <math>2^{b+1} - M = 16 - 10 = 6</math>.
 
{| style="margin:0"
{|border="0" cellspacing="8" cellpadding="0"
|-valign="top"
|
{| class="wikitable" style="margin:0 1em 0 0"
{|border="1" class="wikitable"
|-
!colspan="2"|Encoding of quotient part
Line 95:
|}
|
{|border class="1wikitable" classstyle="wikitablemargin:0"
|-
!colspan="4"|Encoding of remainder part
Line 124:
 
For example, with a Rice–Golomb encoding using parameter {{math|''M'' {{=}} 10}}, the decimal number 42 would first be split into {{mvar|q}} = 4 and {{mvar|r}} = 2, and would be encoded as qcode({{mvar|q}}),rcode({{mvar|r}}) = qcode(4),rcode(2) = 11110,010 (you don't need to encode the separating comma in the output stream, because the 0 at the end of the {{mvar|q}} code is enough to say when {{mvar|q}} ends and {{mvar|r}} begins ; both the qcode and rcode are self-delimited).
 
 
 
== Use for run-length encoding ==