List of usage examples for java.lang Integer MIN_VALUE
int MIN_VALUE
To view the source code for java.lang Integer MIN_VALUE.
Click Source Link
From source file:Main.java
public static int safeLongToInt(long l) throws IllegalArgumentException { if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw new IllegalArgumentException(l + " cannot be cast to int without changing its value."); }// www .j a v a 2s . co m return (int) l; }
From source file:ardufocuser.starfocusing.Utils.java
/** * Calcula valores de luz maximos y minimos de la matriz imagen. *///from w ww .j av a 2 s.c o m public static int[] computeMinMax(int[][] pixels) { int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; for (int x = 0; x < pixels.length; x++) { for (int y = 0; y < pixels[0].length; y++) { if (min > pixels[x][y]) { min = pixels[x][y]; } if (max < pixels[x][y]) { max = pixels[x][y]; } } } return new int[] { min, max }; }
From source file:Main.java
/** * Subtract two integers, checking for overflow. * /*from ww w . j a v a 2 s . com*/ * @param x the minuend * @param y the subtrahend * @return the difference <code>x-y</code> * @throws ArithmeticException if the result can not be represented as an * int * @since 1.1 */ public static int subAndCheck(int x, int y) { long s = (long) x - (long) y; if (s < Integer.MIN_VALUE || s > Integer.MAX_VALUE) { throw new ArithmeticException("overflow: subtract"); } return (int) s; }
From source file:Main.java
/** * Returns the version code of the application. * * @return The version code of the application. *//*www .j a v a 2s . c om*/ public static int getAppVersion(@NonNull final Context context) { try { final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return packageInfo.versionCode; } catch (PackageManager.NameNotFoundException ignore) { // ignore } return Integer.MIN_VALUE; }
From source file:com.linkedin.pinot.perf.ForwardIndexWriterBenchmark.java
public static void convertRawToForwardIndex(File rawFile) throws Exception { List<String> lines = IOUtils.readLines(new FileReader(rawFile)); int totalDocs = lines.size(); int max = Integer.MIN_VALUE; int maxNumberOfMultiValues = Integer.MIN_VALUE; int totalNumValues = 0; int data[][] = new int[totalDocs][]; for (int i = 0; i < lines.size(); i++) { String line = lines.get(i); String[] split = line.split(","); totalNumValues = totalNumValues + split.length; if (split.length > maxNumberOfMultiValues) { maxNumberOfMultiValues = split.length; }// ww w.j a v a 2 s . c om data[i] = new int[split.length]; for (int j = 0; j < split.length; j++) { String token = split[j]; int val = Integer.parseInt(token); data[i][j] = val; if (val > max) { max = val; } } } int maxBitsNeeded = (int) Math.ceil(Math.log(max) / Math.log(2)); int size = 2048; int[] offsets = new int[size]; int bitMapSize = 0; File outputFile = new File("output.mv.fwd"); FixedBitMultiValueWriter fixedBitSkipListSCMVWriter = new FixedBitMultiValueWriter(outputFile, totalDocs, totalNumValues, maxBitsNeeded); for (int i = 0; i < totalDocs; i++) { fixedBitSkipListSCMVWriter.setIntArray(i, data[i]); if (i % size == size - 1) { MutableRoaringBitmap rr1 = MutableRoaringBitmap.bitmapOf(offsets); ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); rr1.serialize(dos); dos.close(); // System.out.println("Chunk " + i / size + " bitmap size:" + bos.size()); bitMapSize += bos.size(); } else if (i == totalDocs - 1) { MutableRoaringBitmap rr1 = MutableRoaringBitmap.bitmapOf(Arrays.copyOf(offsets, i % size)); ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); rr1.serialize(dos); dos.close(); // System.out.println("Chunk " + i / size + " bitmap size:" + bos.size()); bitMapSize += bos.size(); } } fixedBitSkipListSCMVWriter.close(); System.out.println("Output file size:" + outputFile.length()); System.out.println("totalNumberOfDoc\t\t\t:" + totalDocs); System.out.println("totalNumberOfValues\t\t\t:" + totalNumValues); System.out.println("chunk size\t\t\t\t:" + size); System.out.println("Num chunks\t\t\t\t:" + totalDocs / size); int numChunks = totalDocs / size + 1; int totalBits = (totalNumValues * maxBitsNeeded); int dataSizeinBytes = (totalBits + 7) / 8; System.out.println("Raw data size with fixed bit encoding\t:" + dataSizeinBytes); System.out.println("\nPer encoding size"); System.out.println(); System.out.println("size (offset + length)\t\t\t:" + ((totalDocs * (4 + 4)) + dataSizeinBytes)); System.out.println(); System.out.println("size (offset only)\t\t\t:" + ((totalDocs * (4)) + dataSizeinBytes)); System.out.println(); System.out.println("bitMapSize\t\t\t\t:" + bitMapSize); System.out.println("size (with bitmap)\t\t\t:" + (bitMapSize + (numChunks * 4) + dataSizeinBytes)); System.out.println(); System.out.println("Custom Bitset\t\t\t\t:" + (totalNumValues + 7) / 8); System.out.println("size (with custom bitset)\t\t\t:" + (((totalNumValues + 7) / 8) + (numChunks * 4) + dataSizeinBytes)); }
From source file:Main.java
public static boolean isPosible(Rectangle2D.Double r) { if ((r.getMaxX() > Integer.MAX_VALUE) || (r.getMaxY() > Integer.MAX_VALUE) || (r.getMinX() < Integer.MIN_VALUE) || (r.getMinY() < Integer.MIN_VALUE) || (r.getWidth() > Integer.MAX_VALUE) || (r.getHeight() > Integer.MAX_VALUE)) { return false; }// w w w. jav a 2 s . c o m return true; }
From source file:fr.shywim.antoinedaniel.utils.GcmUtils.java
public static String getRegistrationId(Context context) { final SharedPreferences prefs = context.getSharedPreferences(AppConstants.GOOGLE_PREFS, Context.MODE_PRIVATE); String registrationId = prefs.getString(AppConstants.GOOGLE_GCM_REGID, ""); if (registrationId.isEmpty()) { return ""; }/*w w w.j a v a 2 s .c o m*/ // Check if app was updated; if so, it must clear the registration ID // since the existing regID is not guaranteed to work with the new // app version. int registeredVersion = prefs.getInt(AppConstants.GOOGLE_GCM_APPVER, Integer.MIN_VALUE); int currentVersion = Utils.getAppVersion(context); if (registeredVersion != currentVersion) { return ""; } return registrationId; }
From source file:Main.java
/** * Multiply two integers, checking for overflow. * //from ww w . ja v a2 s. c om * @param x a factor * @param y a factor * @return the product <code>x*y</code> * @throws ArithmeticException if the result can not be represented as an * int * @since 1.1 */ public static int mulAndCheck(int x, int y) { long m = ((long) x) * ((long) y); if (m < Integer.MIN_VALUE || m > Integer.MAX_VALUE) { throw new ArithmeticException("overflow: mul"); } return (int) m; }
From source file:net.sf.sprockets.sql.Statements.java
/** * Execute the query, get the int value in the first row and column of the result set, and close * the statement.//from w w w . j a v a 2s . c o m * * @param stmt * must already have parameters set * @return {@link Integer#MIN_VALUE} if the result set is empty */ public static int firstInt(PreparedStatement stmt) throws SQLException { ResultSet rs = stmt.executeQuery(); int i = rs.next() ? rs.getInt(1) : Integer.MIN_VALUE; stmt.close(); return i; }
From source file:com.home.ln_spring.ch5.lifecycle.SimpleBean.java
public void init() { System.out.println("Initialising bean (AGE " + Integer.MIN_VALUE + ")"); if (name == null) { System.out.println("Using default name"); name = DEFAULT_NAME;/*from w w w . j ava 2 s . co m*/ } if (age == Integer.MIN_VALUE) { throw new IllegalArgumentException("You must set age property " + SimpleBean.class); } }