1 /*
2 * arbitrary precision integers
3 * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * arbitrary precision integers
25 * @author Michael Niedermayer <michaelni@gmx.at>
26 */
27
31
33 int i, carry=0;
34
36 carry= (carry>>16) + a.
v[i] + b.
v[i];
38 }
40 }
41
43 int i, carry=0;
44
46 carry= (carry>>16) + a.
v[i] - b.
v[i];
48 }
50 }
51
53 int i;
54
58 }
59 return -1;
60 }
61
64 int i, j;
67
68 memset(&out, 0, sizeof(out));
69
70 for(i=0; i<na; i++){
71 unsigned int carry=0;
72
75 carry= (carry>>16) + out.
v[j] + a.
v[i]*b.
v[j-i];
77 }
78 }
79
81 }
82
84 int i;
86 if(v) return (v>>16)|1;
87
89 int v= a.
v[i] - b.
v[i];
90 if(v) return (v>>16)|1;
91 }
92 return 0;
93 }
94
97 int i;
98
100 unsigned int index= i + (s>>4);
102 if(index+1<AV_INTEGER_SIZE) v = a.
v[index+1]<<16;
103 if(index <AV_INTEGER_SIZE) v+= a.
v[
index ];
104 out.
v[i]= v >> (s&15);
105 }
107 }
108
112 if(!quot) quot = "_temp;
113
116
117 if(i > 0)
119
121
122 while(i-- >= 0){
127 }
129 }
131 }
132
136 return quot;
137 }
138
141 int i;
142
145 a>>=16;
146 }
148 }
149
151 int i;
153
155 out = (out<<16) + a.
v[i];
156 }
158 }
159
160 #ifdef TEST
161
163 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
164 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
165 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
166 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
167 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
168 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
169 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
170 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
171 };
172
175
176 for(a=7; a<256*256*256; a+=13215){
177 for(b=3; b<256*256*256; b+=27118){
180
192 }
193 }
194 return 0;
195 }
196 #endif