1 /*
2 * rational numbers
3 * Copyright (c) 2003 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
24
26 {
29 static const int64_t numlist[] = {
30 INT64_MIN, INT64_MIN+1, INT64_MAX, INT32_MIN, INT32_MAX, 1,0,-1,
31 123456789, INT32_MAX-1, INT32_MAX+1LL, UINT32_MAX-1, UINT32_MAX, UINT32_MAX+1LL
32 };
33
34 for (
a.num = -2;
a.num <= 2;
a.num++) {
35 for (
a.den = -2;
a.den <= 2;
a.den++) {
36 for (
b.num = -2;
b.num <= 2;
b.num++) {
37 for (
b.den = -2;
b.den <= 2;
b.den++) {
41 if (d > 0) d = 1;
42 else if (d < 0) d = -1;
43 else if (d != d) d = INT_MIN;
46 a.den,
b.num,
b.den,
c,d);
48 if(
b.den && (
r.num*
a.den !=
a.num*
r.den || !
r.num != !
a.num || !
r.den != !
a.den))
50 }
51 }
52 }
53 }
54
57
61 continue;
66
68 continue;
70
73
75 continue;
77 continue;
79 continue;
80
81 // Special exception for INT64_MIN, remove this in case INT64_MIN is handled without off by 1 error
83 continue;
84
86 }
87 }
88 }
89
90 for (
a.num = 1;
a.num <= 10;
a.num++) {
91 for (
a.den = 1;
a.den <= 10;
a.den++) {
93 continue;
94 for (
b.num = 1;
b.num <= 10;
b.num++) {
95 for (
b.den = 1;
b.den <= 10;
b.den++) {
96 int start;
98 continue;
100 continue;
101 for (start = 0; start < 10 ; start++) {
102 int acc= start;
104
105 for (
i = 0;
i<100;
i++) {
108 if (
FFABS(acc - exact) > 2) {
110 a.den,
b.num,
b.den, acc, exact);
111 return 1;
112 }
113 }
114 }
115 }
116 }
117 }
118 }
119
120 for (
a.den = 1;
a.den < 0x100000000U/3;
a.den*=3) {
121 for (
a.num = -1;
a.num < (1<<27);
a.num += 1 +
a.num/100) {
127 return 1;
128 }
129
130 }
131 }
132
133 return 0;
134 }