List of usage examples for java.lang Long toBinaryString
public static String toBinaryString(long i)
From source file:de.cosmocode.palava.store.AbstractStoreTest.java
/** * Tests {@link Store#create(InputStream)} with a custom {@link IdGenerator}. * /*from w w w . j av a 2 s . com*/ * @throws IOException should not happen */ @Test public void createCustomGenerator() throws IOException { final String identifier = Long.toBinaryString(System.nanoTime()); final IdGenerator generator = EasyMock.createMock("identifier", IdGenerator.class); EasyMock.expect(generator.generate()).andReturn(identifier); EasyMock.replay(generator); final Store unit = unitWithGenerator(generator); final InputStream stream = getClass().getClassLoader().getResourceAsStream("willi.png"); Assert.assertNotNull(stream); final String generatedIdentifier = unit.create(stream); Assert.assertEquals(identifier, generatedIdentifier); EasyMock.verify(generator); }
From source file:fr.amap.lidar.amapvox.voxelisation.postproc.MultiBandRaster.java
public static BSQ computeRaster(float startingHeight, float step, int bandNumber, int resolution, VoxelSpaceInfos infos, Voxel[][][] voxels, Raster dtm) { float[] altitudes = new float[bandNumber]; for (int i = 0; i < bandNumber; i++) { altitudes[i] = startingHeight + (i * step); }// w ww . j a v a 2 s . c o m float scale = (float) (resolution / infos.getResolution()); int rasterXSize = (int) (Math.ceil(infos.getSplit().x / scale)); int rasterYSize = (int) (Math.ceil(infos.getSplit().y / scale)); BHeader header = new BHeader(rasterXSize, rasterYSize, altitudes.length, BCommon.NumberOfBits.N_BITS_32); header.setUlxmap(infos.getMinCorner().x + (resolution / 2.0f)); header.setUlymap(infos.getMinCorner().y - (infos.getResolution() / 2.0f) + (infos.getSplit().y * infos.getResolution())); header.setXdim(resolution); header.setYdim(resolution); BSQ raster = new BSQ(null, header); Statistic[][][] padMean = new Statistic[rasterXSize][rasterYSize][altitudes.length]; if (dtm != null) { if (altitudes.length > 0) { float altitudeMin = altitudes[0]; for (int i = 0; i < infos.getSplit().x; i++) { for (int j = infos.getSplit().y - 1; j >= 0; j--) { for (int k = 0; k < infos.getSplit().z; k++) { Voxel vox = voxels[i][j][k]; //on calcule l'indice de la couche auquel appartient le voxel if (vox != null && vox.ground_distance > altitudeMin) { int layer = (int) ((vox.ground_distance - altitudeMin) / step); if (layer < altitudes.length) { int indiceI = (int) (i / scale); int indiceJ = (int) (j / scale); if (padMean[indiceI][indiceJ][layer] == null) { padMean[indiceI][indiceJ][layer] = new Statistic(); } if (!Float.isNaN(vox.PadBVTotal)) { padMean[indiceI][indiceJ][layer].addValue(vox.PadBVTotal); } } } } } } long l = 4294967295L; try { //on crit la moyenne for (int i = 0; i < rasterXSize; i++) { for (int j = rasterYSize - 1, j2 = 0; j >= 0; j--, j2++) { for (int k = 0; k < altitudes.length; k++) { if (padMean[i][j][k] != null) { double meanPAD = padMean[i][j][k].getMean(); //float value = (meanOfPAD-0)/(MAX_PAD-0); long value = (long) ((meanPAD / (double) infos.getMaxPAD()) * (l)); String binaryString = Long.toBinaryString(value); byte[] bval = new BigInteger(binaryString, 2).toByteArray(); ArrayUtils.reverse(bval); byte b0 = 0x0, b1 = 0x0, b2 = 0x0, b3 = 0x0; if (bval.length > 0) { b0 = bval[0]; } if (bval.length > 1) { b1 = bval[1]; } if (bval.length > 2) { b2 = bval[2]; } if (bval.length > 3) { b3 = bval[3]; } raster.setPixel(i, j2, k, b0, b1, b2, b3); } } } } } catch (Exception ex) { LOGGER.error(ex); } } } return raster; }
From source file:org.jenkinsci.plugins.registry.notification.webhook.dockerregistry.DockerRegistryPushNotification.java
public String sha() { return Util.getDigestOf("dockerRegistryNotification:" + repoName + Long.toBinaryString(getReceived())); }
From source file:org.jenkinsci.plugins.registry.notification.webhook.dockerhub.DockerHubPushNotification.java
public String sha() { return Util.getDigestOf("dockerHubNotification:" + repoName + Long.toBinaryString(getReceived())); }
From source file:org.wikidata.wdtk.storage.datastructures.BitVectorImpl.java
/** * @param word/*from w ww . j a v a 2 s. co m*/ * word to be rendered * @return a string representation of a <i>word</i> with the least * significant bit first */ static String wordToString(long word) { String binaryDigits = String.format("%" + WORD_SIZE + "s", Long.toBinaryString(word)).replace(' ', '0'); return (new StringBuilder(binaryDigits)).reverse().toString(); }
From source file:org.jenkinsci.plugins.dockerhub.notification.webhook.WebHookPayload.java
public String sha() { return Util.getDigestOf("dockerHubNotification:" + repoName + Long.toBinaryString(received)); }
From source file:org.apache.carbondata.core.util.CarbonUtil.java
/** * This method will be used to update the dimension cardinality * * @param dimCardinality/*from w w w . j ava2 s .c o m*/ * @return new increment cardinality */ public static int[] getIncrementedCardinality(int[] dimCardinality) { // get the cardinality incr factor final int incrValue = CarbonCommonConstants.CARDINALITY_INCREMENT_VALUE_DEFAULT_VAL; int perIncr = 0; int remainder = 0; int[] newDimsC = new int[dimCardinality.length]; for (int i = 0; i < dimCardinality.length; i++) { // get the incr perIncr = (dimCardinality[i] * incrValue) / CONST_HUNDRED; // if per incr is more than one the add to cardinality if (perIncr > 0) { newDimsC[i] = dimCardinality[i] + perIncr; } else { // else add one newDimsC[i] = dimCardinality[i] + 1; } // check whether its in boundary condition remainder = newDimsC[i] % CONST_EIGHT; if (remainder == CONST_SEVEN) { // then incr cardinality by 1 newDimsC[i] = dimCardinality[i] + 1; } } // get the log bits of cardinality for (int i = 0; i < newDimsC.length; i++) { newDimsC[i] = Long.toBinaryString(newDimsC[i]).length(); } return newDimsC; }
From source file:com.google.uzaygezen.core.LongBitVector.java
@Override public String toString() { return StringUtils.leftPad(Long.toBinaryString(data), size, '0'); }
From source file:org.apache.carbondata.core.util.CarbonUtil.java
public static int getIncrementedCardinality(int dimCardinality) { // get the cardinality incr factor final int incrValue = CarbonCommonConstants.CARDINALITY_INCREMENT_VALUE_DEFAULT_VAL; int perIncr = 0; int remainder = 0; int newDimsC = 0; // get the incr perIncr = (dimCardinality * incrValue) / CONST_HUNDRED; // if per incr is more than one the add to cardinality if (perIncr > 0) { newDimsC = dimCardinality + perIncr; } else {// w w w . j a v a 2 s .c o m // else add one newDimsC = dimCardinality + 1; } // check whether its in boundary condition remainder = newDimsC % CONST_EIGHT; if (remainder == CONST_SEVEN) { // then incr cardinality by 1 newDimsC = dimCardinality + 1; } newDimsC = Long.toBinaryString(newDimsC).length(); // get the log bits of cardinality return newDimsC; }
From source file:org.apache.carbondata.core.util.CarbonUtil.java
/** * This method will be used to update the dimension cardinality * * @param dimCardinality/*w w w.ja v a 2 s . c o m*/ * @return new increment cardinality */ public static int[] getIncrementedCardinalityFullyFilled(int[] dimCardinality) { int[] newDimsC = new int[dimCardinality.length]; // get the log bits of cardinality for (int i = 0; i < dimCardinality.length; i++) { if (dimCardinality[i] == 0) { //Array or struct type may have higher value newDimsC[i] = 64; } else { int bitsLength = Long.toBinaryString(dimCardinality[i]).length(); int div = bitsLength / 8; int mod = bitsLength % 8; if (mod > 0) { newDimsC[i] = 8 * (div + 1); } else { newDimsC[i] = bitsLength; } } } return newDimsC; }