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 reportError(String message)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 intCheckDiv(String desc, int result, int dividend, int divisor)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 } intCheckRem(String desc, int result, int dividend, int divisor)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 } longCheckDiv(String desc, long result, long dividend, long divisor)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 } longCheckRem(String desc, long result, long dividend, long divisor)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 idiv_by_pow2_0(int x)58 public static int idiv_by_pow2_0(int x) {return x / 1;} idiv_by_pow2_1(int x)59 public static int idiv_by_pow2_1(int x) {return x / 2;} idiv_by_pow2_2(int x)60 public static int idiv_by_pow2_2(int x) {return x / 4;} idiv_by_pow2_3(int x)61 public static int idiv_by_pow2_3(int x) {return x / 8;} idiv_by_pow2_4(int x)62 public static int idiv_by_pow2_4(int x) {return x / 16;} idiv_by_pow2_5(int x)63 public static int idiv_by_pow2_5(int x) {return x / 32;} idiv_by_pow2_6(int x)64 public static int idiv_by_pow2_6(int x) {return x / 64;} idiv_by_pow2_7(int x)65 public static int idiv_by_pow2_7(int x) {return x / 128;} idiv_by_pow2_8(int x)66 public static int idiv_by_pow2_8(int x) {return x / 256;} idiv_by_pow2_9(int x)67 public static int idiv_by_pow2_9(int x) {return x / 512;} idiv_by_pow2_10(int x)68 public static int idiv_by_pow2_10(int x) {return x / 1024;} idiv_by_pow2_11(int x)69 public static int idiv_by_pow2_11(int x) {return x / 2048;} idiv_by_pow2_12(int x)70 public static int idiv_by_pow2_12(int x) {return x / 4096;} idiv_by_pow2_13(int x)71 public static int idiv_by_pow2_13(int x) {return x / 8192;} idiv_by_pow2_14(int x)72 public static int idiv_by_pow2_14(int x) {return x / 16384;} idiv_by_pow2_15(int x)73 public static int idiv_by_pow2_15(int x) {return x / 32768;} idiv_by_pow2_16(int x)74 public static int idiv_by_pow2_16(int x) {return x / 65536;} idiv_by_pow2_17(int x)75 public static int idiv_by_pow2_17(int x) {return x / 131072;} idiv_by_pow2_18(int x)76 public static int idiv_by_pow2_18(int x) {return x / 262144;} idiv_by_pow2_19(int x)77 public static int idiv_by_pow2_19(int x) {return x / 524288;} idiv_by_pow2_20(int x)78 public static int idiv_by_pow2_20(int x) {return x / 1048576;} idiv_by_pow2_21(int x)79 public static int idiv_by_pow2_21(int x) {return x / 2097152;} idiv_by_pow2_22(int x)80 public static int idiv_by_pow2_22(int x) {return x / 4194304;} idiv_by_pow2_23(int x)81 public static int idiv_by_pow2_23(int x) {return x / 8388608;} idiv_by_pow2_24(int x)82 public static int idiv_by_pow2_24(int x) {return x / 16777216;} idiv_by_pow2_25(int x)83 public static int idiv_by_pow2_25(int x) {return x / 33554432;} idiv_by_pow2_26(int x)84 public static int idiv_by_pow2_26(int x) {return x / 67108864;} idiv_by_pow2_27(int x)85 public static int idiv_by_pow2_27(int x) {return x / 134217728;} idiv_by_pow2_28(int x)86 public static int idiv_by_pow2_28(int x) {return x / 268435456;} idiv_by_pow2_29(int x)87 public static int idiv_by_pow2_29(int x) {return x / 536870912;} idiv_by_pow2_30(int x)88 public static int idiv_by_pow2_30(int x) {return x / 1073741824;} idiv_by_small_0(int x)89 public static int idiv_by_small_0(int x) {return x / 3;} idiv_by_small_1(int x)90 public static int idiv_by_small_1(int x) {return x / 5;} idiv_by_small_2(int x)91 public static int idiv_by_small_2(int x) {return x / 6;} idiv_by_small_3(int x)92 public static int idiv_by_small_3(int x) {return x / 7;} idiv_by_small_4(int x)93 public static int idiv_by_small_4(int x) {return x / 9;} idiv_by_small_5(int x)94 public static int idiv_by_small_5(int x) {return x / 10;} idiv_by_small_6(int x)95 public static int idiv_by_small_6(int x) {return x / 11;} idiv_by_small_7(int x)96 public static int idiv_by_small_7(int x) {return x / 12;} idiv_by_small_8(int x)97 public static int idiv_by_small_8(int x) {return x / 13;} idiv_by_small_9(int x)98 public static int idiv_by_small_9(int x) {return x / 14;} idiv_by_small_10(int x)99 public static int idiv_by_small_10(int x) {return x / 15;} irem_by_pow2_0(int x)100 public static int irem_by_pow2_0(int x) {return x % 1;} irem_by_pow2_1(int x)101 public static int irem_by_pow2_1(int x) {return x % 2;} irem_by_pow2_2(int x)102 public static int irem_by_pow2_2(int x) {return x % 4;} irem_by_pow2_3(int x)103 public static int irem_by_pow2_3(int x) {return x % 8;} irem_by_pow2_4(int x)104 public static int irem_by_pow2_4(int x) {return x % 16;} irem_by_pow2_5(int x)105 public static int irem_by_pow2_5(int x) {return x % 32;} irem_by_pow2_6(int x)106 public static int irem_by_pow2_6(int x) {return x % 64;} irem_by_pow2_7(int x)107 public static int irem_by_pow2_7(int x) {return x % 128;} irem_by_pow2_8(int x)108 public static int irem_by_pow2_8(int x) {return x % 256;} irem_by_pow2_9(int x)109 public static int irem_by_pow2_9(int x) {return x % 512;} irem_by_pow2_10(int x)110 public static int irem_by_pow2_10(int x) {return x % 1024;} irem_by_pow2_11(int x)111 public static int irem_by_pow2_11(int x) {return x % 2048;} irem_by_pow2_12(int x)112 public static int irem_by_pow2_12(int x) {return x % 4096;} irem_by_pow2_13(int x)113 public static int irem_by_pow2_13(int x) {return x % 8192;} irem_by_pow2_14(int x)114 public static int irem_by_pow2_14(int x) {return x % 16384;} irem_by_pow2_15(int x)115 public static int irem_by_pow2_15(int x) {return x % 32768;} irem_by_pow2_16(int x)116 public static int irem_by_pow2_16(int x) {return x % 65536;} irem_by_pow2_17(int x)117 public static int irem_by_pow2_17(int x) {return x % 131072;} irem_by_pow2_18(int x)118 public static int irem_by_pow2_18(int x) {return x % 262144;} irem_by_pow2_19(int x)119 public static int irem_by_pow2_19(int x) {return x % 524288;} irem_by_pow2_20(int x)120 public static int irem_by_pow2_20(int x) {return x % 1048576;} irem_by_pow2_21(int x)121 public static int irem_by_pow2_21(int x) {return x % 2097152;} irem_by_pow2_22(int x)122 public static int irem_by_pow2_22(int x) {return x % 4194304;} irem_by_pow2_23(int x)123 public static int irem_by_pow2_23(int x) {return x % 8388608;} irem_by_pow2_24(int x)124 public static int irem_by_pow2_24(int x) {return x % 16777216;} irem_by_pow2_25(int x)125 public static int irem_by_pow2_25(int x) {return x % 33554432;} irem_by_pow2_26(int x)126 public static int irem_by_pow2_26(int x) {return x % 67108864;} irem_by_pow2_27(int x)127 public static int irem_by_pow2_27(int x) {return x % 134217728;} irem_by_pow2_28(int x)128 public static int irem_by_pow2_28(int x) {return x % 268435456;} irem_by_pow2_29(int x)129 public static int irem_by_pow2_29(int x) {return x % 536870912;} irem_by_pow2_30(int x)130 public static int irem_by_pow2_30(int x) {return x % 1073741824;} ldiv_by_pow2_0(long x)131 public static long ldiv_by_pow2_0(long x) {return x / 1l;} ldiv_by_pow2_1(long x)132 public static long ldiv_by_pow2_1(long x) {return x / 2l;} ldiv_by_pow2_2(long x)133 public static long ldiv_by_pow2_2(long x) {return x / 4l;} ldiv_by_pow2_3(long x)134 public static long ldiv_by_pow2_3(long x) {return x / 8l;} ldiv_by_pow2_4(long x)135 public static long ldiv_by_pow2_4(long x) {return x / 16l;} ldiv_by_pow2_5(long x)136 public static long ldiv_by_pow2_5(long x) {return x / 32l;} ldiv_by_pow2_6(long x)137 public static long ldiv_by_pow2_6(long x) {return x / 64l;} ldiv_by_pow2_7(long x)138 public static long ldiv_by_pow2_7(long x) {return x / 128l;} ldiv_by_pow2_8(long x)139 public static long ldiv_by_pow2_8(long x) {return x / 256l;} ldiv_by_pow2_9(long x)140 public static long ldiv_by_pow2_9(long x) {return x / 512l;} ldiv_by_pow2_10(long x)141 public static long ldiv_by_pow2_10(long x) {return x / 1024l;} ldiv_by_pow2_11(long x)142 public static long ldiv_by_pow2_11(long x) {return x / 2048l;} ldiv_by_pow2_12(long x)143 public static long ldiv_by_pow2_12(long x) {return x / 4096l;} ldiv_by_pow2_13(long x)144 public static long ldiv_by_pow2_13(long x) {return x / 8192l;} ldiv_by_pow2_14(long x)145 public static long ldiv_by_pow2_14(long x) {return x / 16384l;} ldiv_by_pow2_15(long x)146 public static long ldiv_by_pow2_15(long x) {return x / 32768l;} ldiv_by_pow2_16(long x)147 public static long ldiv_by_pow2_16(long x) {return x / 65536l;} ldiv_by_pow2_17(long x)148 public static long ldiv_by_pow2_17(long x) {return x / 131072l;} ldiv_by_pow2_18(long x)149 public static long ldiv_by_pow2_18(long x) {return x / 262144l;} ldiv_by_pow2_19(long x)150 public static long ldiv_by_pow2_19(long x) {return x / 524288l;} ldiv_by_pow2_20(long x)151 public static long ldiv_by_pow2_20(long x) {return x / 1048576l;} ldiv_by_pow2_21(long x)152 public static long ldiv_by_pow2_21(long x) {return x / 2097152l;} ldiv_by_pow2_22(long x)153 public static long ldiv_by_pow2_22(long x) {return x / 4194304l;} ldiv_by_pow2_23(long x)154 public static long ldiv_by_pow2_23(long x) {return x / 8388608l;} ldiv_by_pow2_24(long x)155 public static long ldiv_by_pow2_24(long x) {return x / 16777216l;} ldiv_by_pow2_25(long x)156 public static long ldiv_by_pow2_25(long x) {return x / 33554432l;} ldiv_by_pow2_26(long x)157 public static long ldiv_by_pow2_26(long x) {return x / 67108864l;} ldiv_by_pow2_27(long x)158 public static long ldiv_by_pow2_27(long x) {return x / 134217728l;} ldiv_by_pow2_28(long x)159 public static long ldiv_by_pow2_28(long x) {return x / 268435456l;} ldiv_by_pow2_29(long x)160 public static long ldiv_by_pow2_29(long x) {return x / 536870912l;} ldiv_by_pow2_30(long x)161 public static long ldiv_by_pow2_30(long x) {return x / 1073741824l;} ldiv_by_pow2_31(long x)162 public static long ldiv_by_pow2_31(long x) {return x / 2147483648l;} ldiv_by_pow2_32(long x)163 public static long ldiv_by_pow2_32(long x) {return x / 4294967296l;} ldiv_by_pow2_33(long x)164 public static long ldiv_by_pow2_33(long x) {return x / 8589934592l;} ldiv_by_pow2_34(long x)165 public static long ldiv_by_pow2_34(long x) {return x / 17179869184l;} ldiv_by_pow2_35(long x)166 public static long ldiv_by_pow2_35(long x) {return x / 34359738368l;} ldiv_by_pow2_36(long x)167 public static long ldiv_by_pow2_36(long x) {return x / 68719476736l;} ldiv_by_pow2_37(long x)168 public static long ldiv_by_pow2_37(long x) {return x / 137438953472l;} ldiv_by_pow2_38(long x)169 public static long ldiv_by_pow2_38(long x) {return x / 274877906944l;} ldiv_by_pow2_39(long x)170 public static long ldiv_by_pow2_39(long x) {return x / 549755813888l;} ldiv_by_pow2_40(long x)171 public static long ldiv_by_pow2_40(long x) {return x / 1099511627776l;} ldiv_by_pow2_41(long x)172 public static long ldiv_by_pow2_41(long x) {return x / 2199023255552l;} ldiv_by_pow2_42(long x)173 public static long ldiv_by_pow2_42(long x) {return x / 4398046511104l;} ldiv_by_pow2_43(long x)174 public static long ldiv_by_pow2_43(long x) {return x / 8796093022208l;} ldiv_by_pow2_44(long x)175 public static long ldiv_by_pow2_44(long x) {return x / 17592186044416l;} ldiv_by_pow2_45(long x)176 public static long ldiv_by_pow2_45(long x) {return x / 35184372088832l;} ldiv_by_pow2_46(long x)177 public static long ldiv_by_pow2_46(long x) {return x / 70368744177664l;} ldiv_by_pow2_47(long x)178 public static long ldiv_by_pow2_47(long x) {return x / 140737488355328l;} ldiv_by_pow2_48(long x)179 public static long ldiv_by_pow2_48(long x) {return x / 281474976710656l;} ldiv_by_pow2_49(long x)180 public static long ldiv_by_pow2_49(long x) {return x / 562949953421312l;} ldiv_by_pow2_50(long x)181 public static long ldiv_by_pow2_50(long x) {return x / 1125899906842624l;} ldiv_by_pow2_51(long x)182 public static long ldiv_by_pow2_51(long x) {return x / 2251799813685248l;} ldiv_by_pow2_52(long x)183 public static long ldiv_by_pow2_52(long x) {return x / 4503599627370496l;} ldiv_by_pow2_53(long x)184 public static long ldiv_by_pow2_53(long x) {return x / 9007199254740992l;} ldiv_by_pow2_54(long x)185 public static long ldiv_by_pow2_54(long x) {return x / 18014398509481984l;} ldiv_by_pow2_55(long x)186 public static long ldiv_by_pow2_55(long x) {return x / 36028797018963968l;} ldiv_by_pow2_56(long x)187 public static long ldiv_by_pow2_56(long x) {return x / 72057594037927936l;} ldiv_by_pow2_57(long x)188 public static long ldiv_by_pow2_57(long x) {return x / 144115188075855872l;} ldiv_by_pow2_58(long x)189 public static long ldiv_by_pow2_58(long x) {return x / 288230376151711744l;} ldiv_by_pow2_59(long x)190 public static long ldiv_by_pow2_59(long x) {return x / 576460752303423488l;} ldiv_by_pow2_60(long x)191 public static long ldiv_by_pow2_60(long x) {return x / 1152921504606846976l;} ldiv_by_pow2_61(long x)192 public static long ldiv_by_pow2_61(long x) {return x / 2305843009213693952l;} ldiv_by_pow2_62(long x)193 public static long ldiv_by_pow2_62(long x) {return x / 4611686018427387904l;} ldiv_by_small_0(long x)194 public static long ldiv_by_small_0(long x) {return x / 3l;} ldiv_by_small_1(long x)195 public static long ldiv_by_small_1(long x) {return x / 5l;} ldiv_by_small_2(long x)196 public static long ldiv_by_small_2(long x) {return x / 6l;} ldiv_by_small_3(long x)197 public static long ldiv_by_small_3(long x) {return x / 7l;} ldiv_by_small_4(long x)198 public static long ldiv_by_small_4(long x) {return x / 9l;} ldiv_by_small_5(long x)199 public static long ldiv_by_small_5(long x) {return x / 10l;} ldiv_by_small_6(long x)200 public static long ldiv_by_small_6(long x) {return x / 11l;} ldiv_by_small_7(long x)201 public static long ldiv_by_small_7(long x) {return x / 12l;} ldiv_by_small_8(long x)202 public static long ldiv_by_small_8(long x) {return x / 13l;} ldiv_by_small_9(long x)203 public static long ldiv_by_small_9(long x) {return x / 14l;} ldiv_by_small_10(long x)204 public static long ldiv_by_small_10(long x) {return x / 15l;} lrem_by_pow2_0(long x)205 public static long lrem_by_pow2_0(long x) {return x % 1l;} lrem_by_pow2_1(long x)206 public static long lrem_by_pow2_1(long x) {return x % 2l;} lrem_by_pow2_2(long x)207 public static long lrem_by_pow2_2(long x) {return x % 4l;} lrem_by_pow2_3(long x)208 public static long lrem_by_pow2_3(long x) {return x % 8l;} lrem_by_pow2_4(long x)209 public static long lrem_by_pow2_4(long x) {return x % 16l;} lrem_by_pow2_5(long x)210 public static long lrem_by_pow2_5(long x) {return x % 32l;} lrem_by_pow2_6(long x)211 public static long lrem_by_pow2_6(long x) {return x % 64l;} lrem_by_pow2_7(long x)212 public static long lrem_by_pow2_7(long x) {return x % 128l;} lrem_by_pow2_8(long x)213 public static long lrem_by_pow2_8(long x) {return x % 256l;} lrem_by_pow2_9(long x)214 public static long lrem_by_pow2_9(long x) {return x % 512l;} lrem_by_pow2_10(long x)215 public static long lrem_by_pow2_10(long x) {return x % 1024l;} lrem_by_pow2_11(long x)216 public static long lrem_by_pow2_11(long x) {return x % 2048l;} lrem_by_pow2_12(long x)217 public static long lrem_by_pow2_12(long x) {return x % 4096l;} lrem_by_pow2_13(long x)218 public static long lrem_by_pow2_13(long x) {return x % 8192l;} lrem_by_pow2_14(long x)219 public static long lrem_by_pow2_14(long x) {return x % 16384l;} lrem_by_pow2_15(long x)220 public static long lrem_by_pow2_15(long x) {return x % 32768l;} lrem_by_pow2_16(long x)221 public static long lrem_by_pow2_16(long x) {return x % 65536l;} lrem_by_pow2_17(long x)222 public static long lrem_by_pow2_17(long x) {return x % 131072l;} lrem_by_pow2_18(long x)223 public static long lrem_by_pow2_18(long x) {return x % 262144l;} lrem_by_pow2_19(long x)224 public static long lrem_by_pow2_19(long x) {return x % 524288l;} lrem_by_pow2_20(long x)225 public static long lrem_by_pow2_20(long x) {return x % 1048576l;} lrem_by_pow2_21(long x)226 public static long lrem_by_pow2_21(long x) {return x % 2097152l;} lrem_by_pow2_22(long x)227 public static long lrem_by_pow2_22(long x) {return x % 4194304l;} lrem_by_pow2_23(long x)228 public static long lrem_by_pow2_23(long x) {return x % 8388608l;} lrem_by_pow2_24(long x)229 public static long lrem_by_pow2_24(long x) {return x % 16777216l;} lrem_by_pow2_25(long x)230 public static long lrem_by_pow2_25(long x) {return x % 33554432l;} lrem_by_pow2_26(long x)231 public static long lrem_by_pow2_26(long x) {return x % 67108864l;} lrem_by_pow2_27(long x)232 public static long lrem_by_pow2_27(long x) {return x % 134217728l;} lrem_by_pow2_28(long x)233 public static long lrem_by_pow2_28(long x) {return x % 268435456l;} lrem_by_pow2_29(long x)234 public static long lrem_by_pow2_29(long x) {return x % 536870912l;} lrem_by_pow2_30(long x)235 public static long lrem_by_pow2_30(long x) {return x % 1073741824l;} lrem_by_pow2_31(long x)236 public static long lrem_by_pow2_31(long x) {return x % 2147483648l;} lrem_by_pow2_32(long x)237 public static long lrem_by_pow2_32(long x) {return x % 4294967296l;} lrem_by_pow2_33(long x)238 public static long lrem_by_pow2_33(long x) {return x % 8589934592l;} lrem_by_pow2_34(long x)239 public static long lrem_by_pow2_34(long x) {return x % 17179869184l;} lrem_by_pow2_35(long x)240 public static long lrem_by_pow2_35(long x) {return x % 34359738368l;} lrem_by_pow2_36(long x)241 public static long lrem_by_pow2_36(long x) {return x % 68719476736l;} lrem_by_pow2_37(long x)242 public static long lrem_by_pow2_37(long x) {return x % 137438953472l;} lrem_by_pow2_38(long x)243 public static long lrem_by_pow2_38(long x) {return x % 274877906944l;} lrem_by_pow2_39(long x)244 public static long lrem_by_pow2_39(long x) {return x % 549755813888l;} lrem_by_pow2_40(long x)245 public static long lrem_by_pow2_40(long x) {return x % 1099511627776l;} lrem_by_pow2_41(long x)246 public static long lrem_by_pow2_41(long x) {return x % 2199023255552l;} lrem_by_pow2_42(long x)247 public static long lrem_by_pow2_42(long x) {return x % 4398046511104l;} lrem_by_pow2_43(long x)248 public static long lrem_by_pow2_43(long x) {return x % 8796093022208l;} lrem_by_pow2_44(long x)249 public static long lrem_by_pow2_44(long x) {return x % 17592186044416l;} lrem_by_pow2_45(long x)250 public static long lrem_by_pow2_45(long x) {return x % 35184372088832l;} lrem_by_pow2_46(long x)251 public static long lrem_by_pow2_46(long x) {return x % 70368744177664l;} lrem_by_pow2_47(long x)252 public static long lrem_by_pow2_47(long x) {return x % 140737488355328l;} lrem_by_pow2_48(long x)253 public static long lrem_by_pow2_48(long x) {return x % 281474976710656l;} lrem_by_pow2_49(long x)254 public static long lrem_by_pow2_49(long x) {return x % 562949953421312l;} lrem_by_pow2_50(long x)255 public static long lrem_by_pow2_50(long x) {return x % 1125899906842624l;} lrem_by_pow2_51(long x)256 public static long lrem_by_pow2_51(long x) {return x % 2251799813685248l;} lrem_by_pow2_52(long x)257 public static long lrem_by_pow2_52(long x) {return x % 4503599627370496l;} lrem_by_pow2_53(long x)258 public static long lrem_by_pow2_53(long x) {return x % 9007199254740992l;} lrem_by_pow2_54(long x)259 public static long lrem_by_pow2_54(long x) {return x % 18014398509481984l;} lrem_by_pow2_55(long x)260 public static long lrem_by_pow2_55(long x) {return x % 36028797018963968l;} lrem_by_pow2_56(long x)261 public static long lrem_by_pow2_56(long x) {return x % 72057594037927936l;} lrem_by_pow2_57(long x)262 public static long lrem_by_pow2_57(long x) {return x % 144115188075855872l;} lrem_by_pow2_58(long x)263 public static long lrem_by_pow2_58(long x) {return x % 288230376151711744l;} lrem_by_pow2_59(long x)264 public static long lrem_by_pow2_59(long x) {return x % 576460752303423488l;} lrem_by_pow2_60(long x)265 public static long lrem_by_pow2_60(long x) {return x % 1152921504606846976l;} lrem_by_pow2_61(long x)266 public static long lrem_by_pow2_61(long x) {return x % 2305843009213693952l;} lrem_by_pow2_62(long x)267 public static long lrem_by_pow2_62(long x) {return x % 4611686018427387904l;} 268 intCheckAll(int x)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 longCheckAll(long x)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 main(String[] args)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 } 530