Rice coding: Difference between revisions

(→‎{{header|Wren}}: Updated in line with Julia and also added basic codings for k= 4.)
Line 177:
}
 
System.print("Basic Rice coding (k = 2):")
for (i in 0..10) {
var res = Rice.encode(i, 2)
Line 183:
}
 
System.print("\nExtended Rice coding (k == 2):")
for (i in -10..10) {
var res = Rice.encodeEx(i, 2)
Line 197:
{{out}}
<pre>
Basic Rice coding (k = 2):
0 -> 0000000 -> 0
1 -> 0001001 -> 1
2 -> 0010010 -> 2
3 -> 0011011 -> 3
4 -> 100001000 -> 4
5 -> 100011001 -> 5
6 -> 100101010 -> 6
7 -> 100111011 -> 7
8 -> 11000011000 -> 8
9 -> 11000111001 -> 9
10 -> 11001011010 -> 10
 
Extended Rice coding (k == 2):
-10 -> 111100111111011 -> -10
-9 -> 111100011111001 -> -9
-8 -> 1110011111011 -> -8
-7 -> 1110001111001 -> -7
-6 -> 11001111011 -> -6
-5 -> 11000111001 -> -5
-4 -> 100111011 -> -4
-3 -> 100011001 -> -3
-2 -> 0011011 -> -2
-1 -> 0001001 -> -1
0 -> 0000000 -> 0
1 -> 0010010 -> 1
2 -> 100001000 -> 2
3 -> 100101010 -> 3
4 -> 11000011000 -> 4
5 -> 11001011010 -> 5
6 -> 1110000111000 -> 6
7 -> 1110010111010 -> 7
8 -> 111100001111000 -> 8
9 -> 111100101111010 -> 9
10 -> 11111000011111000 -> 10
 
Basic Rice coding (k == 4):
9,482

edits