Home | History | Annotate | Download | only in regress_37875803
      1 // Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
      2 // for details. All rights reserved. Use of this source code is governed by a
      3 // BSD-style license that can be found in the LICENSE file.
      4 package regress_37875803;
      5 
      6 public class Regress {
      7 
      8   private static int digitSub(int codePoint) {
      9     int result = -888;
     10     if ('a' <= codePoint && codePoint <= 'z') {
     11       result = 10 + (codePoint - 'a');
     12     } else if ('A' <= codePoint && codePoint <= 'Z') {
     13       result = 10 + (codePoint - 'A');
     14     }
     15     if (result < 0) {
     16       throw new RuntimeException("codePoint = " + codePoint + " result = " + result);
     17     }
     18     return result;
     19   }
     20 
     21   private static int digitSubLeft(int codePoint) {
     22     int result = -888;
     23     if ('a' <= codePoint && codePoint <= 'z') {
     24       result = 10 + ('a' - codePoint);
     25     } else if ('A' <= codePoint && codePoint <= 'Z') {
     26       result = 10 + ('A' - codePoint);
     27     }
     28     if (result < 0) {
     29       throw new RuntimeException("codePoint = " + codePoint + " result = " + result);
     30     }
     31     return result;
     32   }
     33 
     34   private static int digitAdd(int codePoint) {
     35     int result = -888;
     36     if ('a' <= codePoint && codePoint <= 'z') {
     37       result = 10 + (codePoint + 'a');
     38     } else if ('A' <= codePoint && codePoint <= 'Z') {
     39       result = 10 + (codePoint + 'A');
     40     }
     41     if (result < 0) {
     42       throw new RuntimeException("codePoint = " + codePoint + " result = " + result);
     43     }
     44     return result;
     45   }
     46 
     47   private static int digitOr(int codePoint) {
     48     int result = -888;
     49     if ('a' <= codePoint && codePoint <= 'z') {
     50       result = 10 + (codePoint | 'a');
     51     } else if ('A' <= codePoint && codePoint <= 'Z') {
     52       result = 10 + (codePoint | 'A');
     53     }
     54     if (result < 0) {
     55       throw new RuntimeException("codePoint = " + codePoint + " result = " + result);
     56     }
     57     return result;
     58   }
     59 
     60   public static void main(String[] args) {
     61     System.out.println(digitSub((int) 'a'));
     62     System.out.println(digitSub((int) 'A'));
     63     System.out.println(digitSubLeft((int) 'a'));
     64     System.out.println(digitSubLeft((int) 'A'));
     65     System.out.println(digitAdd((int) 'a'));
     66     System.out.println(digitAdd((int) 'A'));
     67     System.out.println(digitOr((int) 'a'));
     68     System.out.println(digitOr((int) 'A'));
     69   }
     70 }
     71