1503
|
1 // $HeadURL$
|
|
2 // $Date$
|
|
3 // $Author$
|
|
4
|
|
5 // @author@ <niqbmozgvx@mailinator.com>
|
|
6 // @date@ 2007-04-15
|
|
7 // @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1150
|
|
8 // @desc@ [Issue 1150] Compiler creates wrong code
|
|
9
|
|
10 module dstress.run.o.odd_bug_15_A;
|
|
11
|
|
12 class RangeCoder {
|
|
13 uint[258] cumCount;
|
|
14 uint lower;
|
|
15 uint upper;
|
|
16 ulong range;
|
|
17
|
|
18 this() {
|
|
19 for (int i=0; i < cumCount.length; i++){
|
|
20 cumCount[i] = i;
|
|
21 }
|
|
22 lower = 0;
|
|
23 upper = 0xffffffff;
|
|
24 range = 0x100000000;
|
|
25 }
|
|
26
|
|
27 void encode(uint symbol) {
|
|
28 uint total = cumCount[length - 1];
|
|
29 upper = lower + cast(uint)((cumCount[symbol+1] * range) / total) - 1;
|
|
30 lower = lower + cast(uint)((cumCount[symbol] * range) / total);
|
|
31 }
|
|
32
|
|
33 }
|
|
34
|
|
35 int main() {
|
|
36 RangeCoder rc = new RangeCoder();
|
|
37 rc.encode(77);
|
|
38 return 0;
|
|
39 }
|