Matteo Franchin | 7c6c2ac | 2014-07-01 18:03:08 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | public class Main { |
| 18 | public static int num_errors = 0; |
| 19 | |
| 20 | public static void reportError(String message) { |
| 21 | if (num_errors == 10) { |
| 22 | System.out.println("Omitting other error messages..."); |
| 23 | } else if (num_errors < 10) { |
| 24 | System.out.println(message); |
| 25 | } |
| 26 | num_errors += 1; |
| 27 | } |
| 28 | |
| 29 | public static void intCheckDiv(String desc, int result, int dividend, int divisor) { |
| 30 | int correct_result = dividend / divisor; |
| 31 | if (result != correct_result) { |
| 32 | reportError(desc + "(" + dividend + ") == " + result + |
| 33 | " should be " + correct_result); |
| 34 | } |
| 35 | } |
| 36 | public static void intCheckRem(String desc, int result, int dividend, int divisor) { |
| 37 | int correct_result = dividend % divisor; |
| 38 | if (result != correct_result) { |
| 39 | reportError(desc + "(" + dividend + ") == " + result + |
| 40 | " should be " + correct_result); |
| 41 | } |
| 42 | } |
| 43 | public static void longCheckDiv(String desc, long result, long dividend, long divisor) { |
| 44 | long correct_result = dividend / divisor; |
| 45 | if (result != correct_result) { |
| 46 | reportError(desc + "(" + dividend + ") == " + result + |
| 47 | " should be " + correct_result); |
| 48 | } |
| 49 | } |
| 50 | public static void longCheckRem(String desc, long result, long dividend, long divisor) { |
| 51 | long correct_result = dividend % divisor; |
| 52 | if (result != correct_result) { |
| 53 | reportError(desc + "(" + dividend + ") == " + result + |
| 54 | " should be " + correct_result); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | public static int idiv_by_pow2_0(int x) {return x / 1;} |
| 59 | public static int idiv_by_pow2_1(int x) {return x / 2;} |
| 60 | public static int idiv_by_pow2_2(int x) {return x / 4;} |
| 61 | public static int idiv_by_pow2_3(int x) {return x / 8;} |
| 62 | public static int idiv_by_pow2_4(int x) {return x / 16;} |
| 63 | public static int idiv_by_pow2_5(int x) {return x / 32;} |
| 64 | public static int idiv_by_pow2_6(int x) {return x / 64;} |
| 65 | public static int idiv_by_pow2_7(int x) {return x / 128;} |
| 66 | public static int idiv_by_pow2_8(int x) {return x / 256;} |
| 67 | public static int idiv_by_pow2_9(int x) {return x / 512;} |
| 68 | public static int idiv_by_pow2_10(int x) {return x / 1024;} |
| 69 | public static int idiv_by_pow2_11(int x) {return x / 2048;} |
| 70 | public static int idiv_by_pow2_12(int x) {return x / 4096;} |
| 71 | public static int idiv_by_pow2_13(int x) {return x / 8192;} |
| 72 | public static int idiv_by_pow2_14(int x) {return x / 16384;} |
| 73 | public static int idiv_by_pow2_15(int x) {return x / 32768;} |
| 74 | public static int idiv_by_pow2_16(int x) {return x / 65536;} |
| 75 | public static int idiv_by_pow2_17(int x) {return x / 131072;} |
| 76 | public static int idiv_by_pow2_18(int x) {return x / 262144;} |
| 77 | public static int idiv_by_pow2_19(int x) {return x / 524288;} |
| 78 | public static int idiv_by_pow2_20(int x) {return x / 1048576;} |
| 79 | public static int idiv_by_pow2_21(int x) {return x / 2097152;} |
| 80 | public static int idiv_by_pow2_22(int x) {return x / 4194304;} |
| 81 | public static int idiv_by_pow2_23(int x) {return x / 8388608;} |
| 82 | public static int idiv_by_pow2_24(int x) {return x / 16777216;} |
| 83 | public static int idiv_by_pow2_25(int x) {return x / 33554432;} |
| 84 | public static int idiv_by_pow2_26(int x) {return x / 67108864;} |
| 85 | public static int idiv_by_pow2_27(int x) {return x / 134217728;} |
| 86 | public static int idiv_by_pow2_28(int x) {return x / 268435456;} |
| 87 | public static int idiv_by_pow2_29(int x) {return x / 536870912;} |
| 88 | public static int idiv_by_pow2_30(int x) {return x / 1073741824;} |
| 89 | public static int idiv_by_small_0(int x) {return x / 3;} |
| 90 | public static int idiv_by_small_1(int x) {return x / 5;} |
| 91 | public static int idiv_by_small_2(int x) {return x / 6;} |
| 92 | public static int idiv_by_small_3(int x) {return x / 7;} |
| 93 | public static int idiv_by_small_4(int x) {return x / 9;} |
| 94 | public static int idiv_by_small_5(int x) {return x / 10;} |
| 95 | public static int idiv_by_small_6(int x) {return x / 11;} |
| 96 | public static int idiv_by_small_7(int x) {return x / 12;} |
| 97 | public static int idiv_by_small_8(int x) {return x / 13;} |
| 98 | public static int idiv_by_small_9(int x) {return x / 14;} |
| 99 | public static int idiv_by_small_10(int x) {return x / 15;} |
| 100 | public static int irem_by_pow2_0(int x) {return x % 1;} |
| 101 | public static int irem_by_pow2_1(int x) {return x % 2;} |
| 102 | public static int irem_by_pow2_2(int x) {return x % 4;} |
| 103 | public static int irem_by_pow2_3(int x) {return x % 8;} |
| 104 | public static int irem_by_pow2_4(int x) {return x % 16;} |
| 105 | public static int irem_by_pow2_5(int x) {return x % 32;} |
| 106 | public static int irem_by_pow2_6(int x) {return x % 64;} |
| 107 | public static int irem_by_pow2_7(int x) {return x % 128;} |
| 108 | public static int irem_by_pow2_8(int x) {return x % 256;} |
| 109 | public static int irem_by_pow2_9(int x) {return x % 512;} |
| 110 | public static int irem_by_pow2_10(int x) {return x % 1024;} |
| 111 | public static int irem_by_pow2_11(int x) {return x % 2048;} |
| 112 | public static int irem_by_pow2_12(int x) {return x % 4096;} |
| 113 | public static int irem_by_pow2_13(int x) {return x % 8192;} |
| 114 | public static int irem_by_pow2_14(int x) {return x % 16384;} |
| 115 | public static int irem_by_pow2_15(int x) {return x % 32768;} |
| 116 | public static int irem_by_pow2_16(int x) {return x % 65536;} |
| 117 | public static int irem_by_pow2_17(int x) {return x % 131072;} |
| 118 | public static int irem_by_pow2_18(int x) {return x % 262144;} |
| 119 | public static int irem_by_pow2_19(int x) {return x % 524288;} |
| 120 | public static int irem_by_pow2_20(int x) {return x % 1048576;} |
| 121 | public static int irem_by_pow2_21(int x) {return x % 2097152;} |
| 122 | public static int irem_by_pow2_22(int x) {return x % 4194304;} |
| 123 | public static int irem_by_pow2_23(int x) {return x % 8388608;} |
| 124 | public static int irem_by_pow2_24(int x) {return x % 16777216;} |
| 125 | public static int irem_by_pow2_25(int x) {return x % 33554432;} |
| 126 | public static int irem_by_pow2_26(int x) {return x % 67108864;} |
| 127 | public static int irem_by_pow2_27(int x) {return x % 134217728;} |
| 128 | public static int irem_by_pow2_28(int x) {return x % 268435456;} |
| 129 | public static int irem_by_pow2_29(int x) {return x % 536870912;} |
| 130 | public static int irem_by_pow2_30(int x) {return x % 1073741824;} |
| 131 | public static long ldiv_by_pow2_0(long x) {return x / 1l;} |
| 132 | public static long ldiv_by_pow2_1(long x) {return x / 2l;} |
| 133 | public static long ldiv_by_pow2_2(long x) {return x / 4l;} |
| 134 | public static long ldiv_by_pow2_3(long x) {return x / 8l;} |
| 135 | public static long ldiv_by_pow2_4(long x) {return x / 16l;} |
| 136 | public static long ldiv_by_pow2_5(long x) {return x / 32l;} |
| 137 | public static long ldiv_by_pow2_6(long x) {return x / 64l;} |
| 138 | public static long ldiv_by_pow2_7(long x) {return x / 128l;} |
| 139 | public static long ldiv_by_pow2_8(long x) {return x / 256l;} |
| 140 | public static long ldiv_by_pow2_9(long x) {return x / 512l;} |
| 141 | public static long ldiv_by_pow2_10(long x) {return x / 1024l;} |
| 142 | public static long ldiv_by_pow2_11(long x) {return x / 2048l;} |
| 143 | public static long ldiv_by_pow2_12(long x) {return x / 4096l;} |
| 144 | public static long ldiv_by_pow2_13(long x) {return x / 8192l;} |
| 145 | public static long ldiv_by_pow2_14(long x) {return x / 16384l;} |
| 146 | public static long ldiv_by_pow2_15(long x) {return x / 32768l;} |
| 147 | public static long ldiv_by_pow2_16(long x) {return x / 65536l;} |
| 148 | public static long ldiv_by_pow2_17(long x) {return x / 131072l;} |
| 149 | public static long ldiv_by_pow2_18(long x) {return x / 262144l;} |
| 150 | public static long ldiv_by_pow2_19(long x) {return x / 524288l;} |
| 151 | public static long ldiv_by_pow2_20(long x) {return x / 1048576l;} |
| 152 | public static long ldiv_by_pow2_21(long x) {return x / 2097152l;} |
| 153 | public static long ldiv_by_pow2_22(long x) {return x / 4194304l;} |
| 154 | public static long ldiv_by_pow2_23(long x) {return x / 8388608l;} |
| 155 | public static long ldiv_by_pow2_24(long x) {return x / 16777216l;} |
| 156 | public static long ldiv_by_pow2_25(long x) {return x / 33554432l;} |
| 157 | public static long ldiv_by_pow2_26(long x) {return x / 67108864l;} |
| 158 | public static long ldiv_by_pow2_27(long x) {return x / 134217728l;} |
| 159 | public static long ldiv_by_pow2_28(long x) {return x / 268435456l;} |
| 160 | public static long ldiv_by_pow2_29(long x) {return x / 536870912l;} |
| 161 | public static long ldiv_by_pow2_30(long x) {return x / 1073741824l;} |
| 162 | public static long ldiv_by_pow2_31(long x) {return x / 2147483648l;} |
| 163 | public static long ldiv_by_pow2_32(long x) {return x / 4294967296l;} |
| 164 | public static long ldiv_by_pow2_33(long x) {return x / 8589934592l;} |
| 165 | public static long ldiv_by_pow2_34(long x) {return x / 17179869184l;} |
| 166 | public static long ldiv_by_pow2_35(long x) {return x / 34359738368l;} |
| 167 | public static long ldiv_by_pow2_36(long x) {return x / 68719476736l;} |
| 168 | public static long ldiv_by_pow2_37(long x) {return x / 137438953472l;} |
| 169 | public static long ldiv_by_pow2_38(long x) {return x / 274877906944l;} |
| 170 | public static long ldiv_by_pow2_39(long x) {return x / 549755813888l;} |
| 171 | public static long ldiv_by_pow2_40(long x) {return x / 1099511627776l;} |
| 172 | public static long ldiv_by_pow2_41(long x) {return x / 2199023255552l;} |
| 173 | public static long ldiv_by_pow2_42(long x) {return x / 4398046511104l;} |
| 174 | public static long ldiv_by_pow2_43(long x) {return x / 8796093022208l;} |
| 175 | public static long ldiv_by_pow2_44(long x) {return x / 17592186044416l;} |
| 176 | public static long ldiv_by_pow2_45(long x) {return x / 35184372088832l;} |
| 177 | public static long ldiv_by_pow2_46(long x) {return x / 70368744177664l;} |
| 178 | public static long ldiv_by_pow2_47(long x) {return x / 140737488355328l;} |
| 179 | public static long ldiv_by_pow2_48(long x) {return x / 281474976710656l;} |
| 180 | public static long ldiv_by_pow2_49(long x) {return x / 562949953421312l;} |
| 181 | public static long ldiv_by_pow2_50(long x) {return x / 1125899906842624l;} |
| 182 | public static long ldiv_by_pow2_51(long x) {return x / 2251799813685248l;} |
| 183 | public static long ldiv_by_pow2_52(long x) {return x / 4503599627370496l;} |
| 184 | public static long ldiv_by_pow2_53(long x) {return x / 9007199254740992l;} |
| 185 | public static long ldiv_by_pow2_54(long x) {return x / 18014398509481984l;} |
| 186 | public static long ldiv_by_pow2_55(long x) {return x / 36028797018963968l;} |
| 187 | public static long ldiv_by_pow2_56(long x) {return x / 72057594037927936l;} |
| 188 | public static long ldiv_by_pow2_57(long x) {return x / 144115188075855872l;} |
| 189 | public static long ldiv_by_pow2_58(long x) {return x / 288230376151711744l;} |
| 190 | public static long ldiv_by_pow2_59(long x) {return x / 576460752303423488l;} |
| 191 | public static long ldiv_by_pow2_60(long x) {return x / 1152921504606846976l;} |
| 192 | public static long ldiv_by_pow2_61(long x) {return x / 2305843009213693952l;} |
| 193 | public static long ldiv_by_pow2_62(long x) {return x / 4611686018427387904l;} |
| 194 | public static long ldiv_by_small_0(long x) {return x / 3l;} |
| 195 | public static long ldiv_by_small_1(long x) {return x / 5l;} |
| 196 | public static long ldiv_by_small_2(long x) {return x / 6l;} |
| 197 | public static long ldiv_by_small_3(long x) {return x / 7l;} |
| 198 | public static long ldiv_by_small_4(long x) {return x / 9l;} |
| 199 | public static long ldiv_by_small_5(long x) {return x / 10l;} |
| 200 | public static long ldiv_by_small_6(long x) {return x / 11l;} |
| 201 | public static long ldiv_by_small_7(long x) {return x / 12l;} |
| 202 | public static long ldiv_by_small_8(long x) {return x / 13l;} |
| 203 | public static long ldiv_by_small_9(long x) {return x / 14l;} |
| 204 | public static long ldiv_by_small_10(long x) {return x / 15l;} |
| 205 | public static long lrem_by_pow2_0(long x) {return x % 1l;} |
| 206 | public static long lrem_by_pow2_1(long x) {return x % 2l;} |
| 207 | public static long lrem_by_pow2_2(long x) {return x % 4l;} |
| 208 | public static long lrem_by_pow2_3(long x) {return x % 8l;} |
| 209 | public static long lrem_by_pow2_4(long x) {return x % 16l;} |
| 210 | public static long lrem_by_pow2_5(long x) {return x % 32l;} |
| 211 | public static long lrem_by_pow2_6(long x) {return x % 64l;} |
| 212 | public static long lrem_by_pow2_7(long x) {return x % 128l;} |
| 213 | public static long lrem_by_pow2_8(long x) {return x % 256l;} |
| 214 | public static long lrem_by_pow2_9(long x) {return x % 512l;} |
| 215 | public static long lrem_by_pow2_10(long x) {return x % 1024l;} |
| 216 | public static long lrem_by_pow2_11(long x) {return x % 2048l;} |
| 217 | public static long lrem_by_pow2_12(long x) {return x % 4096l;} |
| 218 | public static long lrem_by_pow2_13(long x) {return x % 8192l;} |
| 219 | public static long lrem_by_pow2_14(long x) {return x % 16384l;} |
| 220 | public static long lrem_by_pow2_15(long x) {return x % 32768l;} |
| 221 | public static long lrem_by_pow2_16(long x) {return x % 65536l;} |
| 222 | public static long lrem_by_pow2_17(long x) {return x % 131072l;} |
| 223 | public static long lrem_by_pow2_18(long x) {return x % 262144l;} |
| 224 | public static long lrem_by_pow2_19(long x) {return x % 524288l;} |
| 225 | public static long lrem_by_pow2_20(long x) {return x % 1048576l;} |
| 226 | public static long lrem_by_pow2_21(long x) {return x % 2097152l;} |
| 227 | public static long lrem_by_pow2_22(long x) {return x % 4194304l;} |
| 228 | public static long lrem_by_pow2_23(long x) {return x % 8388608l;} |
| 229 | public static long lrem_by_pow2_24(long x) {return x % 16777216l;} |
| 230 | public static long lrem_by_pow2_25(long x) {return x % 33554432l;} |
| 231 | public static long lrem_by_pow2_26(long x) {return x % 67108864l;} |
| 232 | public static long lrem_by_pow2_27(long x) {return x % 134217728l;} |
| 233 | public static long lrem_by_pow2_28(long x) {return x % 268435456l;} |
| 234 | public static long lrem_by_pow2_29(long x) {return x % 536870912l;} |
| 235 | public static long lrem_by_pow2_30(long x) {return x % 1073741824l;} |
| 236 | public static long lrem_by_pow2_31(long x) {return x % 2147483648l;} |
| 237 | public static long lrem_by_pow2_32(long x) {return x % 4294967296l;} |
| 238 | public static long lrem_by_pow2_33(long x) {return x % 8589934592l;} |
| 239 | public static long lrem_by_pow2_34(long x) {return x % 17179869184l;} |
| 240 | public static long lrem_by_pow2_35(long x) {return x % 34359738368l;} |
| 241 | public static long lrem_by_pow2_36(long x) {return x % 68719476736l;} |
| 242 | public static long lrem_by_pow2_37(long x) {return x % 137438953472l;} |
| 243 | public static long lrem_by_pow2_38(long x) {return x % 274877906944l;} |
| 244 | public static long lrem_by_pow2_39(long x) {return x % 549755813888l;} |
| 245 | public static long lrem_by_pow2_40(long x) {return x % 1099511627776l;} |
| 246 | public static long lrem_by_pow2_41(long x) {return x % 2199023255552l;} |
| 247 | public static long lrem_by_pow2_42(long x) {return x % 4398046511104l;} |
| 248 | public static long lrem_by_pow2_43(long x) {return x % 8796093022208l;} |
| 249 | public static long lrem_by_pow2_44(long x) {return x % 17592186044416l;} |
| 250 | public static long lrem_by_pow2_45(long x) {return x % 35184372088832l;} |
| 251 | public static long lrem_by_pow2_46(long x) {return x % 70368744177664l;} |
| 252 | public static long lrem_by_pow2_47(long x) {return x % 140737488355328l;} |
| 253 | public static long lrem_by_pow2_48(long x) {return x % 281474976710656l;} |
| 254 | public static long lrem_by_pow2_49(long x) {return x % 562949953421312l;} |
| 255 | public static long lrem_by_pow2_50(long x) {return x % 1125899906842624l;} |
| 256 | public static long lrem_by_pow2_51(long x) {return x % 2251799813685248l;} |
| 257 | public static long lrem_by_pow2_52(long x) {return x % 4503599627370496l;} |
| 258 | public static long lrem_by_pow2_53(long x) {return x % 9007199254740992l;} |
| 259 | public static long lrem_by_pow2_54(long x) {return x % 18014398509481984l;} |
| 260 | public static long lrem_by_pow2_55(long x) {return x % 36028797018963968l;} |
| 261 | public static long lrem_by_pow2_56(long x) {return x % 72057594037927936l;} |
| 262 | public static long lrem_by_pow2_57(long x) {return x % 144115188075855872l;} |
| 263 | public static long lrem_by_pow2_58(long x) {return x % 288230376151711744l;} |
| 264 | public static long lrem_by_pow2_59(long x) {return x % 576460752303423488l;} |
| 265 | public static long lrem_by_pow2_60(long x) {return x % 1152921504606846976l;} |
| 266 | public static long lrem_by_pow2_61(long x) {return x % 2305843009213693952l;} |
| 267 | public static long lrem_by_pow2_62(long x) {return x % 4611686018427387904l;} |
| 268 | |
| 269 | public static void intCheckAll(int x) { |
| 270 | intCheckDiv("idiv_by_pow2_0", idiv_by_pow2_0(x), x, 1); |
| 271 | intCheckDiv("idiv_by_pow2_1", idiv_by_pow2_1(x), x, 2); |
| 272 | intCheckDiv("idiv_by_pow2_2", idiv_by_pow2_2(x), x, 4); |
| 273 | intCheckDiv("idiv_by_pow2_3", idiv_by_pow2_3(x), x, 8); |
| 274 | intCheckDiv("idiv_by_pow2_4", idiv_by_pow2_4(x), x, 16); |
| 275 | intCheckDiv("idiv_by_pow2_5", idiv_by_pow2_5(x), x, 32); |
| 276 | intCheckDiv("idiv_by_pow2_6", idiv_by_pow2_6(x), x, 64); |
| 277 | intCheckDiv("idiv_by_pow2_7", idiv_by_pow2_7(x), x, 128); |
| 278 | intCheckDiv("idiv_by_pow2_8", idiv_by_pow2_8(x), x, 256); |
| 279 | intCheckDiv("idiv_by_pow2_9", idiv_by_pow2_9(x), x, 512); |
| 280 | intCheckDiv("idiv_by_pow2_10", idiv_by_pow2_10(x), x, 1024); |
| 281 | intCheckDiv("idiv_by_pow2_11", idiv_by_pow2_11(x), x, 2048); |
| 282 | intCheckDiv("idiv_by_pow2_12", idiv_by_pow2_12(x), x, 4096); |
| 283 | intCheckDiv("idiv_by_pow2_13", idiv_by_pow2_13(x), x, 8192); |
| 284 | intCheckDiv("idiv_by_pow2_14", idiv_by_pow2_14(x), x, 16384); |
| 285 | intCheckDiv("idiv_by_pow2_15", idiv_by_pow2_15(x), x, 32768); |
| 286 | intCheckDiv("idiv_by_pow2_16", idiv_by_pow2_16(x), x, 65536); |
| 287 | intCheckDiv("idiv_by_pow2_17", idiv_by_pow2_17(x), x, 131072); |
| 288 | intCheckDiv("idiv_by_pow2_18", idiv_by_pow2_18(x), x, 262144); |
| 289 | intCheckDiv("idiv_by_pow2_19", idiv_by_pow2_19(x), x, 524288); |
| 290 | intCheckDiv("idiv_by_pow2_20", idiv_by_pow2_20(x), x, 1048576); |
| 291 | intCheckDiv("idiv_by_pow2_21", idiv_by_pow2_21(x), x, 2097152); |
| 292 | intCheckDiv("idiv_by_pow2_22", idiv_by_pow2_22(x), x, 4194304); |
| 293 | intCheckDiv("idiv_by_pow2_23", idiv_by_pow2_23(x), x, 8388608); |
| 294 | intCheckDiv("idiv_by_pow2_24", idiv_by_pow2_24(x), x, 16777216); |
| 295 | intCheckDiv("idiv_by_pow2_25", idiv_by_pow2_25(x), x, 33554432); |
| 296 | intCheckDiv("idiv_by_pow2_26", idiv_by_pow2_26(x), x, 67108864); |
| 297 | intCheckDiv("idiv_by_pow2_27", idiv_by_pow2_27(x), x, 134217728); |
| 298 | intCheckDiv("idiv_by_pow2_28", idiv_by_pow2_28(x), x, 268435456); |
| 299 | intCheckDiv("idiv_by_pow2_29", idiv_by_pow2_29(x), x, 536870912); |
| 300 | intCheckDiv("idiv_by_pow2_30", idiv_by_pow2_30(x), x, 1073741824); |
| 301 | intCheckDiv("idiv_by_small_0", idiv_by_small_0(x), x, 3); |
| 302 | intCheckDiv("idiv_by_small_1", idiv_by_small_1(x), x, 5); |
| 303 | intCheckDiv("idiv_by_small_2", idiv_by_small_2(x), x, 6); |
| 304 | intCheckDiv("idiv_by_small_3", idiv_by_small_3(x), x, 7); |
| 305 | intCheckDiv("idiv_by_small_4", idiv_by_small_4(x), x, 9); |
| 306 | intCheckDiv("idiv_by_small_5", idiv_by_small_5(x), x, 10); |
| 307 | intCheckDiv("idiv_by_small_6", idiv_by_small_6(x), x, 11); |
| 308 | intCheckDiv("idiv_by_small_7", idiv_by_small_7(x), x, 12); |
| 309 | intCheckDiv("idiv_by_small_8", idiv_by_small_8(x), x, 13); |
| 310 | intCheckDiv("idiv_by_small_9", idiv_by_small_9(x), x, 14); |
| 311 | intCheckDiv("idiv_by_small_10", idiv_by_small_10(x), x, 15); |
| 312 | intCheckRem("irem_by_pow2_0", irem_by_pow2_0(x), x, 1); |
| 313 | intCheckRem("irem_by_pow2_1", irem_by_pow2_1(x), x, 2); |
| 314 | intCheckRem("irem_by_pow2_2", irem_by_pow2_2(x), x, 4); |
| 315 | intCheckRem("irem_by_pow2_3", irem_by_pow2_3(x), x, 8); |
| 316 | intCheckRem("irem_by_pow2_4", irem_by_pow2_4(x), x, 16); |
| 317 | intCheckRem("irem_by_pow2_5", irem_by_pow2_5(x), x, 32); |
| 318 | intCheckRem("irem_by_pow2_6", irem_by_pow2_6(x), x, 64); |
| 319 | intCheckRem("irem_by_pow2_7", irem_by_pow2_7(x), x, 128); |
| 320 | intCheckRem("irem_by_pow2_8", irem_by_pow2_8(x), x, 256); |
| 321 | intCheckRem("irem_by_pow2_9", irem_by_pow2_9(x), x, 512); |
| 322 | intCheckRem("irem_by_pow2_10", irem_by_pow2_10(x), x, 1024); |
| 323 | intCheckRem("irem_by_pow2_11", irem_by_pow2_11(x), x, 2048); |
| 324 | intCheckRem("irem_by_pow2_12", irem_by_pow2_12(x), x, 4096); |
| 325 | intCheckRem("irem_by_pow2_13", irem_by_pow2_13(x), x, 8192); |
| 326 | intCheckRem("irem_by_pow2_14", irem_by_pow2_14(x), x, 16384); |
| 327 | intCheckRem("irem_by_pow2_15", irem_by_pow2_15(x), x, 32768); |
| 328 | intCheckRem("irem_by_pow2_16", irem_by_pow2_16(x), x, 65536); |
| 329 | intCheckRem("irem_by_pow2_17", irem_by_pow2_17(x), x, 131072); |
| 330 | intCheckRem("irem_by_pow2_18", irem_by_pow2_18(x), x, 262144); |
| 331 | intCheckRem("irem_by_pow2_19", irem_by_pow2_19(x), x, 524288); |
| 332 | intCheckRem("irem_by_pow2_20", irem_by_pow2_20(x), x, 1048576); |
| 333 | intCheckRem("irem_by_pow2_21", irem_by_pow2_21(x), x, 2097152); |
| 334 | intCheckRem("irem_by_pow2_22", irem_by_pow2_22(x), x, 4194304); |
| 335 | intCheckRem("irem_by_pow2_23", irem_by_pow2_23(x), x, 8388608); |
| 336 | intCheckRem("irem_by_pow2_24", irem_by_pow2_24(x), x, 16777216); |
| 337 | intCheckRem("irem_by_pow2_25", irem_by_pow2_25(x), x, 33554432); |
| 338 | intCheckRem("irem_by_pow2_26", irem_by_pow2_26(x), x, 67108864); |
| 339 | intCheckRem("irem_by_pow2_27", irem_by_pow2_27(x), x, 134217728); |
| 340 | intCheckRem("irem_by_pow2_28", irem_by_pow2_28(x), x, 268435456); |
| 341 | intCheckRem("irem_by_pow2_29", irem_by_pow2_29(x), x, 536870912); |
| 342 | intCheckRem("irem_by_pow2_30", irem_by_pow2_30(x), x, 1073741824); |
| 343 | } |
| 344 | |
| 345 | public static void longCheckAll(long x) { |
| 346 | longCheckDiv("ldiv_by_pow2_0", ldiv_by_pow2_0(x), x, 1l); |
| 347 | longCheckDiv("ldiv_by_pow2_1", ldiv_by_pow2_1(x), x, 2l); |
| 348 | longCheckDiv("ldiv_by_pow2_2", ldiv_by_pow2_2(x), x, 4l); |
| 349 | longCheckDiv("ldiv_by_pow2_3", ldiv_by_pow2_3(x), x, 8l); |
| 350 | longCheckDiv("ldiv_by_pow2_4", ldiv_by_pow2_4(x), x, 16l); |
| 351 | longCheckDiv("ldiv_by_pow2_5", ldiv_by_pow2_5(x), x, 32l); |
| 352 | longCheckDiv("ldiv_by_pow2_6", ldiv_by_pow2_6(x), x, 64l); |
| 353 | longCheckDiv("ldiv_by_pow2_7", ldiv_by_pow2_7(x), x, 128l); |
| 354 | longCheckDiv("ldiv_by_pow2_8", ldiv_by_pow2_8(x), x, 256l); |
| 355 | longCheckDiv("ldiv_by_pow2_9", ldiv_by_pow2_9(x), x, 512l); |
| 356 | longCheckDiv("ldiv_by_pow2_10", ldiv_by_pow2_10(x), x, 1024l); |
| 357 | longCheckDiv("ldiv_by_pow2_11", ldiv_by_pow2_11(x), x, 2048l); |
| 358 | longCheckDiv("ldiv_by_pow2_12", ldiv_by_pow2_12(x), x, 4096l); |
| 359 | longCheckDiv("ldiv_by_pow2_13", ldiv_by_pow2_13(x), x, 8192l); |
| 360 | longCheckDiv("ldiv_by_pow2_14", ldiv_by_pow2_14(x), x, 16384l); |
| 361 | longCheckDiv("ldiv_by_pow2_15", ldiv_by_pow2_15(x), x, 32768l); |
| 362 | longCheckDiv("ldiv_by_pow2_16", ldiv_by_pow2_16(x), x, 65536l); |
| 363 | longCheckDiv("ldiv_by_pow2_17", ldiv_by_pow2_17(x), x, 131072l); |
| 364 | longCheckDiv("ldiv_by_pow2_18", ldiv_by_pow2_18(x), x, 262144l); |
| 365 | longCheckDiv("ldiv_by_pow2_19", ldiv_by_pow2_19(x), x, 524288l); |
| 366 | longCheckDiv("ldiv_by_pow2_20", ldiv_by_pow2_20(x), x, 1048576l); |
| 367 | longCheckDiv("ldiv_by_pow2_21", ldiv_by_pow2_21(x), x, 2097152l); |
| 368 | longCheckDiv("ldiv_by_pow2_22", ldiv_by_pow2_22(x), x, 4194304l); |
| 369 | longCheckDiv("ldiv_by_pow2_23", ldiv_by_pow2_23(x), x, 8388608l); |
| 370 | longCheckDiv("ldiv_by_pow2_24", ldiv_by_pow2_24(x), x, 16777216l); |
| 371 | longCheckDiv("ldiv_by_pow2_25", ldiv_by_pow2_25(x), x, 33554432l); |
| 372 | longCheckDiv("ldiv_by_pow2_26", ldiv_by_pow2_26(x), x, 67108864l); |
| 373 | longCheckDiv("ldiv_by_pow2_27", ldiv_by_pow2_27(x), x, 134217728l); |
| 374 | longCheckDiv("ldiv_by_pow2_28", ldiv_by_pow2_28(x), x, 268435456l); |
| 375 | longCheckDiv("ldiv_by_pow2_29", ldiv_by_pow2_29(x), x, 536870912l); |
| 376 | longCheckDiv("ldiv_by_pow2_30", ldiv_by_pow2_30(x), x, 1073741824l); |
| 377 | longCheckDiv("ldiv_by_pow2_31", ldiv_by_pow2_31(x), x, 2147483648l); |
| 378 | longCheckDiv("ldiv_by_pow2_32", ldiv_by_pow2_32(x), x, 4294967296l); |
| 379 | longCheckDiv("ldiv_by_pow2_33", ldiv_by_pow2_33(x), x, 8589934592l); |
| 380 | longCheckDiv("ldiv_by_pow2_34", ldiv_by_pow2_34(x), x, 17179869184l); |
| 381 | longCheckDiv("ldiv_by_pow2_35", ldiv_by_pow2_35(x), x, 34359738368l); |
| 382 | longCheckDiv("ldiv_by_pow2_36", ldiv_by_pow2_36(x), x, 68719476736l); |
| 383 | longCheckDiv("ldiv_by_pow2_37", ldiv_by_pow2_37(x), x, 137438953472l); |
| 384 | longCheckDiv("ldiv_by_pow2_38", ldiv_by_pow2_38(x), x, 274877906944l); |
| 385 | longCheckDiv("ldiv_by_pow2_39", ldiv_by_pow2_39(x), x, 549755813888l); |
| 386 | longCheckDiv("ldiv_by_pow2_40", ldiv_by_pow2_40(x), x, 1099511627776l); |
| 387 | longCheckDiv("ldiv_by_pow2_41", ldiv_by_pow2_41(x), x, 2199023255552l); |
| 388 | longCheckDiv("ldiv_by_pow2_42", ldiv_by_pow2_42(x), x, 4398046511104l); |
| 389 | longCheckDiv("ldiv_by_pow2_43", ldiv_by_pow2_43(x), x, 8796093022208l); |
| 390 | longCheckDiv("ldiv_by_pow2_44", ldiv_by_pow2_44(x), x, 17592186044416l); |
| 391 | longCheckDiv("ldiv_by_pow2_45", ldiv_by_pow2_45(x), x, 35184372088832l); |
| 392 | longCheckDiv("ldiv_by_pow2_46", ldiv_by_pow2_46(x), x, 70368744177664l); |
| 393 | longCheckDiv("ldiv_by_pow2_47", ldiv_by_pow2_47(x), x, 140737488355328l); |
| 394 | longCheckDiv("ldiv_by_pow2_48", ldiv_by_pow2_48(x), x, 281474976710656l); |
| 395 | longCheckDiv("ldiv_by_pow2_49", ldiv_by_pow2_49(x), x, 562949953421312l); |
| 396 | longCheckDiv("ldiv_by_pow2_50", ldiv_by_pow2_50(x), x, 1125899906842624l); |
| 397 | longCheckDiv("ldiv_by_pow2_51", ldiv_by_pow2_51(x), x, 2251799813685248l); |
| 398 | longCheckDiv("ldiv_by_pow2_52", ldiv_by_pow2_52(x), x, 4503599627370496l); |
| 399 | longCheckDiv("ldiv_by_pow2_53", ldiv_by_pow2_53(x), x, 9007199254740992l); |
| 400 | longCheckDiv("ldiv_by_pow2_54", ldiv_by_pow2_54(x), x, 18014398509481984l); |
| 401 | longCheckDiv("ldiv_by_pow2_55", ldiv_by_pow2_55(x), x, 36028797018963968l); |
| 402 | longCheckDiv("ldiv_by_pow2_56", ldiv_by_pow2_56(x), x, 72057594037927936l); |
| 403 | longCheckDiv("ldiv_by_pow2_57", ldiv_by_pow2_57(x), x, 144115188075855872l); |
| 404 | longCheckDiv("ldiv_by_pow2_58", ldiv_by_pow2_58(x), x, 288230376151711744l); |
| 405 | longCheckDiv("ldiv_by_pow2_59", ldiv_by_pow2_59(x), x, 576460752303423488l); |
| 406 | longCheckDiv("ldiv_by_pow2_60", ldiv_by_pow2_60(x), x, 1152921504606846976l); |
| 407 | longCheckDiv("ldiv_by_pow2_61", ldiv_by_pow2_61(x), x, 2305843009213693952l); |
| 408 | longCheckDiv("ldiv_by_pow2_62", ldiv_by_pow2_62(x), x, 4611686018427387904l); |
| 409 | longCheckDiv("ldiv_by_small_0", ldiv_by_small_0(x), x, 3l); |
| 410 | longCheckDiv("ldiv_by_small_1", ldiv_by_small_1(x), x, 5l); |
| 411 | longCheckDiv("ldiv_by_small_2", ldiv_by_small_2(x), x, 6l); |
| 412 | longCheckDiv("ldiv_by_small_3", ldiv_by_small_3(x), x, 7l); |
| 413 | longCheckDiv("ldiv_by_small_4", ldiv_by_small_4(x), x, 9l); |
| 414 | longCheckDiv("ldiv_by_small_5", ldiv_by_small_5(x), x, 10l); |
| 415 | longCheckDiv("ldiv_by_small_6", ldiv_by_small_6(x), x, 11l); |
| 416 | longCheckDiv("ldiv_by_small_7", ldiv_by_small_7(x), x, 12l); |
| 417 | longCheckDiv("ldiv_by_small_8", ldiv_by_small_8(x), x, 13l); |
| 418 | longCheckDiv("ldiv_by_small_9", ldiv_by_small_9(x), x, 14l); |
| 419 | longCheckDiv("ldiv_by_small_10", ldiv_by_small_10(x), x, 15l); |
| 420 | longCheckRem("lrem_by_pow2_0", lrem_by_pow2_0(x), x, 1l); |
| 421 | longCheckRem("lrem_by_pow2_1", lrem_by_pow2_1(x), x, 2l); |
| 422 | longCheckRem("lrem_by_pow2_2", lrem_by_pow2_2(x), x, 4l); |
| 423 | longCheckRem("lrem_by_pow2_3", lrem_by_pow2_3(x), x, 8l); |
| 424 | longCheckRem("lrem_by_pow2_4", lrem_by_pow2_4(x), x, 16l); |
| 425 | longCheckRem("lrem_by_pow2_5", lrem_by_pow2_5(x), x, 32l); |
| 426 | longCheckRem("lrem_by_pow2_6", lrem_by_pow2_6(x), x, 64l); |
| 427 | longCheckRem("lrem_by_pow2_7", lrem_by_pow2_7(x), x, 128l); |
| 428 | longCheckRem("lrem_by_pow2_8", lrem_by_pow2_8(x), x, 256l); |
| 429 | longCheckRem("lrem_by_pow2_9", lrem_by_pow2_9(x), x, 512l); |
| 430 | longCheckRem("lrem_by_pow2_10", lrem_by_pow2_10(x), x, 1024l); |
| 431 | longCheckRem("lrem_by_pow2_11", lrem_by_pow2_11(x), x, 2048l); |
| 432 | longCheckRem("lrem_by_pow2_12", lrem_by_pow2_12(x), x, 4096l); |
| 433 | longCheckRem("lrem_by_pow2_13", lrem_by_pow2_13(x), x, 8192l); |
| 434 | longCheckRem("lrem_by_pow2_14", lrem_by_pow2_14(x), x, 16384l); |
| 435 | longCheckRem("lrem_by_pow2_15", lrem_by_pow2_15(x), x, 32768l); |
| 436 | longCheckRem("lrem_by_pow2_16", lrem_by_pow2_16(x), x, 65536l); |
| 437 | longCheckRem("lrem_by_pow2_17", lrem_by_pow2_17(x), x, 131072l); |
| 438 | longCheckRem("lrem_by_pow2_18", lrem_by_pow2_18(x), x, 262144l); |
| 439 | longCheckRem("lrem_by_pow2_19", lrem_by_pow2_19(x), x, 524288l); |
| 440 | longCheckRem("lrem_by_pow2_20", lrem_by_pow2_20(x), x, 1048576l); |
| 441 | longCheckRem("lrem_by_pow2_21", lrem_by_pow2_21(x), x, 2097152l); |
| 442 | longCheckRem("lrem_by_pow2_22", lrem_by_pow2_22(x), x, 4194304l); |
| 443 | longCheckRem("lrem_by_pow2_23", lrem_by_pow2_23(x), x, 8388608l); |
| 444 | longCheckRem("lrem_by_pow2_24", lrem_by_pow2_24(x), x, 16777216l); |
| 445 | longCheckRem("lrem_by_pow2_25", lrem_by_pow2_25(x), x, 33554432l); |
| 446 | longCheckRem("lrem_by_pow2_26", lrem_by_pow2_26(x), x, 67108864l); |
| 447 | longCheckRem("lrem_by_pow2_27", lrem_by_pow2_27(x), x, 134217728l); |
| 448 | longCheckRem("lrem_by_pow2_28", lrem_by_pow2_28(x), x, 268435456l); |
| 449 | longCheckRem("lrem_by_pow2_29", lrem_by_pow2_29(x), x, 536870912l); |
| 450 | longCheckRem("lrem_by_pow2_30", lrem_by_pow2_30(x), x, 1073741824l); |
| 451 | longCheckRem("lrem_by_pow2_31", lrem_by_pow2_31(x), x, 2147483648l); |
| 452 | longCheckRem("lrem_by_pow2_32", lrem_by_pow2_32(x), x, 4294967296l); |
| 453 | longCheckRem("lrem_by_pow2_33", lrem_by_pow2_33(x), x, 8589934592l); |
| 454 | longCheckRem("lrem_by_pow2_34", lrem_by_pow2_34(x), x, 17179869184l); |
| 455 | longCheckRem("lrem_by_pow2_35", lrem_by_pow2_35(x), x, 34359738368l); |
| 456 | longCheckRem("lrem_by_pow2_36", lrem_by_pow2_36(x), x, 68719476736l); |
| 457 | longCheckRem("lrem_by_pow2_37", lrem_by_pow2_37(x), x, 137438953472l); |
| 458 | longCheckRem("lrem_by_pow2_38", lrem_by_pow2_38(x), x, 274877906944l); |
| 459 | longCheckRem("lrem_by_pow2_39", lrem_by_pow2_39(x), x, 549755813888l); |
| 460 | longCheckRem("lrem_by_pow2_40", lrem_by_pow2_40(x), x, 1099511627776l); |
| 461 | longCheckRem("lrem_by_pow2_41", lrem_by_pow2_41(x), x, 2199023255552l); |
| 462 | longCheckRem("lrem_by_pow2_42", lrem_by_pow2_42(x), x, 4398046511104l); |
| 463 | longCheckRem("lrem_by_pow2_43", lrem_by_pow2_43(x), x, 8796093022208l); |
| 464 | longCheckRem("lrem_by_pow2_44", lrem_by_pow2_44(x), x, 17592186044416l); |
| 465 | longCheckRem("lrem_by_pow2_45", lrem_by_pow2_45(x), x, 35184372088832l); |
| 466 | longCheckRem("lrem_by_pow2_46", lrem_by_pow2_46(x), x, 70368744177664l); |
| 467 | longCheckRem("lrem_by_pow2_47", lrem_by_pow2_47(x), x, 140737488355328l); |
| 468 | longCheckRem("lrem_by_pow2_48", lrem_by_pow2_48(x), x, 281474976710656l); |
| 469 | longCheckRem("lrem_by_pow2_49", lrem_by_pow2_49(x), x, 562949953421312l); |
| 470 | longCheckRem("lrem_by_pow2_50", lrem_by_pow2_50(x), x, 1125899906842624l); |
| 471 | longCheckRem("lrem_by_pow2_51", lrem_by_pow2_51(x), x, 2251799813685248l); |
| 472 | longCheckRem("lrem_by_pow2_52", lrem_by_pow2_52(x), x, 4503599627370496l); |
| 473 | longCheckRem("lrem_by_pow2_53", lrem_by_pow2_53(x), x, 9007199254740992l); |
| 474 | longCheckRem("lrem_by_pow2_54", lrem_by_pow2_54(x), x, 18014398509481984l); |
| 475 | longCheckRem("lrem_by_pow2_55", lrem_by_pow2_55(x), x, 36028797018963968l); |
| 476 | longCheckRem("lrem_by_pow2_56", lrem_by_pow2_56(x), x, 72057594037927936l); |
| 477 | longCheckRem("lrem_by_pow2_57", lrem_by_pow2_57(x), x, 144115188075855872l); |
| 478 | longCheckRem("lrem_by_pow2_58", lrem_by_pow2_58(x), x, 288230376151711744l); |
| 479 | longCheckRem("lrem_by_pow2_59", lrem_by_pow2_59(x), x, 576460752303423488l); |
| 480 | longCheckRem("lrem_by_pow2_60", lrem_by_pow2_60(x), x, 1152921504606846976l); |
| 481 | longCheckRem("lrem_by_pow2_61", lrem_by_pow2_61(x), x, 2305843009213693952l); |
| 482 | longCheckRem("lrem_by_pow2_62", lrem_by_pow2_62(x), x, 4611686018427387904l); |
| 483 | } |
| 484 | |
| 485 | public static void main(String[] args) { |
| 486 | int i; |
| 487 | long l; |
| 488 | |
| 489 | System.out.println("Begin"); |
| 490 | |
| 491 | System.out.println("Int: checking some equally spaced dividends..."); |
| 492 | for (i = -1000; i < 1000; i += 300) { |
| 493 | intCheckAll(i); |
| 494 | intCheckAll(-i); |
| 495 | } |
| 496 | |
| 497 | System.out.println("Int: checking small dividends..."); |
| 498 | for (i = 1; i < 100; i += 1) { |
| 499 | intCheckAll(i); |
| 500 | intCheckAll(-i); |
| 501 | } |
| 502 | |
| 503 | System.out.println("Int: checking big dividends..."); |
| 504 | for (i = 0; i < 100; i += 1) { |
| 505 | intCheckAll(Integer.MAX_VALUE - i); |
| 506 | intCheckAll(Integer.MIN_VALUE + i); |
| 507 | } |
| 508 | |
| 509 | System.out.println("Long: checking some equally spaced dividends..."); |
| 510 | for (l = 0l; l < 1000000000000l; l += 300000000000l) { |
| 511 | longCheckAll(l); |
| 512 | longCheckAll(-l); |
| 513 | } |
| 514 | |
| 515 | System.out.println("Long: checking small dividends..."); |
| 516 | for (l = 1l; l < 100l; l += 1l) { |
| 517 | longCheckAll(l); |
| 518 | longCheckAll(-l); |
| 519 | } |
| 520 | |
| 521 | System.out.println("Long: checking big dividends..."); |
| 522 | for (l = 0l; l < 100l; l += 1l) { |
| 523 | longCheckAll(Long.MAX_VALUE - l); |
| 524 | longCheckAll(Long.MIN_VALUE + l); |
| 525 | } |
| 526 | |
| 527 | System.out.println("End"); |
| 528 | } |
| 529 | } |