List of usage examples for java.math BigInteger ZERO
BigInteger ZERO
To view the source code for java.math BigInteger ZERO.
Click Source Link
From source file:com.ar.dev.tierra.api.dao.impl.FiscalDAOImpl.java
@Override public void factura_a(List<DetalleFactura> detalles, Cliente cliente) { try (PrintWriter ticket = new PrintWriter("command/factura_a.200")) { DecimalFormat decimalFormat = new DecimalFormat(); decimalFormat.setMaximumFractionDigits(1); ticket.println("b" + (char) 28 + cliente.getNombreCliente() + (char) 28 + cliente.getDocumento() + (char) 28 + cliente.getResponsabilidadIva() + (char) 28 + cliente.getTipoDocumento() + (char) 28 + cliente.getDomicilio()); ticket.println("@" + (char) 28 + "A" + (char) 28 + "T"); BigDecimal descuento = new BigDecimal(BigInteger.ZERO); for (DetalleFactura detalle : detalles) { if (detalle.getDescuentoDetalle() != null) { descuento = descuento.add(detalle.getDescuentoDetalle()); }//www . j av a2s . c o m String price = null; BigDecimal sinIVA = detalle.getProducto().getPrecioVenta().subtract(detalle.getProducto() .getPrecioVenta().multiply(new BigDecimal(17.35)).divide(new BigDecimal(100))); price = sinIVA.setScale(4, RoundingMode.HALF_UP).toString(); ticket.println("B" + (char) 28 /*Abrimos linea*/ + detalle.getProducto().getDescripcion() + (char) 28 /*Nombre producto*/ + detalle.getCantidadDetalle() + ".0" + (char) 28 /*Cantidad*/ + price.replace(",", ".") + (char) 28 /*Precio unitario*/ + "21.0" + (char) 28 /*Impuestos IVA*/ + "M" + (char) 28 /*Suma monto*/ + "0.0" + (char) 28 /*Impuestos internos*/ + "0" + (char) 28 /*Parametro display*/ + "b"); /*Cierra de linea*/ } if (!descuento.equals(new BigDecimal(BigInteger.ZERO))) { ticket.println("T" + (char) 28 /*Abrimos linea descuento*/ + "Descuento: " + (char) 28 /*Texto a mostrar*/ + descuento + (char) 28 /*Monto descuento*/ + "m" + (char) 28 /*m: descuento, M: aumento*/ + "0" + (char) 28 /*parametro display*/ + "T"); /*cierre linea descuento*/ } ticket.println("E"); } catch (FileNotFoundException ex) { Logger.getLogger(FiscalDAOImpl.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.redhat.lightblue.metadata.types.BooleanTypeTest.java
@Test public void testCompareNotEqual() { assertEquals(booleanType.compare((Object) BigInteger.ZERO, (Object) BigInteger.ONE), -1); }
From source file:org.limewire.mojito.util.DHTSizeEstimator.java
/** * Adds the approximate DHT size as returned by a remote Node. * The average of the remote DHT sizes is incorporated into into * our local computation.// w ww.j a va2 s .c o m */ public synchronized void addEstimatedRemoteSize(BigInteger remoteSize) { if (!ContextSettings.COUNT_REMOTE_SIZE.getValue()) { // Clear the list of remotely estimated DHT sizes as they're // no longer needed. remoteSizeHistory.clear(); return; } if (remoteSize.compareTo(BigInteger.ZERO) == 0) { return; } if (remoteSize.compareTo(BigInteger.ZERO) < 0 || remoteSize.compareTo(MAXIMUM) > 0) { if (LOG.isWarnEnabled()) { LOG.warn(remoteSize + " is an illegal argument"); } return; } remoteSizeHistory.add(remoteSize); // Adjust the size of the List. The Setting is SIMPP-able // and may change! int maxRemoteHistorySize = ContextSettings.MAX_REMOTE_HISTORY_SIZE.getValue(); while (remoteSizeHistory.size() > maxRemoteHistorySize && !remoteSizeHistory.isEmpty()) { remoteSizeHistory.remove(0); } }
From source file:com.ar.dev.tierra.api.controller.NotaCreditoController.java
@RequestMapping(value = "/update", method = RequestMethod.POST) public ResponseEntity<?> update(OAuth2Authentication authentication, @RequestBody NotaCredito notaCredito) { Usuarios user = facadeService.getUsuariosDAO().findUsuarioByUsername(authentication.getName()); notaCredito.setUsuarioModificacion(user.getIdUsuario()); notaCredito.setFechaModificacion(new Date()); BigDecimal montoUpdate = new BigDecimal(BigInteger.ZERO); List<DetalleNotaCredito> list = facadeService.getDetalleNotaCreditoDAO() .getByNotaCredito(notaCredito.getIdNotaCredito()); for (DetalleNotaCredito detalleNotaCredito : list) { montoUpdate = montoUpdate.add(detalleNotaCredito.getMonto()); }/*from w w w. j a va2s .co m*/ notaCredito.setMontoTotal(montoUpdate); facadeService.getNotaCreditoDAO().update(notaCredito); JsonResponse msg = new JsonResponse("Success", "Nota de credito modificada con exito"); return new ResponseEntity<>(msg, HttpStatus.OK); }
From source file:com.redhat.lightblue.metadata.types.BigIntegerTypeTest.java
@Test public void testCompareNotEqual() { assertEquals(bigIntegerType.compare((Object) BigInteger.ZERO, (Object) BigInteger.ONE), -1); }
From source file:org.apache.blur.command.ShardCommandManagerTest.java
@Test public void testGetCommands() { Map<String, BigInteger> commands = _manager.getCommands(); assertEquals(4, commands.size());//from w ww . j av a2 s .c om assertTrue(commands.containsKey("wait")); assertTrue(commands.containsKey("error")); assertTrue(commands.containsKey("RunSlowForTesting")); assertTrue(commands.containsKey("currentUser")); assertEquals(BigInteger.ZERO, commands.get("wait")); }
From source file:org.codice.ddf.spatial.ogc.wps.process.endpoint.Validator.java
/** * @param inputs//from w ww. j a v a2 s . c om * @param inputDescription * @throws WpsException */ public static void validateProcessInputsMinMaxOccurs(List<Data> inputs, DataDescription inputDescription) { if (CollectionUtils.isEmpty(inputs)) { if (BigInteger.ZERO.equals(inputDescription.getMinOccurs())) { return; } else { throw new WpsException("Too few input items have been specified.", "TooFewInputs", inputDescription.getId()); } } BigInteger maxOccurs = inputDescription.getMaxOccurs() == null ? BigInteger.ONE : inputDescription.getMaxOccurs(); if (inputs.size() > maxOccurs.intValue()) { throw new WpsException("Too many input items have been specified.", "TooManyInputs", inputDescription.getId()); } BigInteger minOccurs = inputDescription.getMinOccurs() == null ? BigInteger.ONE : inputDescription.getMinOccurs(); if (inputs.size() < minOccurs.intValue()) { throw new WpsException("Too few input items have been specified.", "TooFewInputs", inputDescription.getId()); } inputs.forEach(input -> validateProcessInputData(input, inputDescription)); }
From source file:com.baasbox.db.DbHelper.java
public static BigInteger getDBStorageFreeSpace() { if (BBConfiguration.getDBSizeThreshold() != BigInteger.ZERO) return BBConfiguration.getDBSizeThreshold(); return BigInteger.valueOf(new File(BBConfiguration.getDBDir()).getFreeSpace()); }
From source file:com.google.uzaygezen.core.BitVectorTest.java
private void checkCopyFromToBigInteger(Function<Integer, BitVector> factory) { for (int j = 0; j < 128; j++) { BitVector b = factory.apply(j);//from w w w .j a v a 2 s . co m boolean[] bits = new boolean[b.size()]; for (int k = 0; k < b.size(); ++k) { bits[k] = random.nextBoolean(); } BigInteger expected = BigInteger.ZERO; for (int k = 0; k < b.size(); ++k) { b.set(k, bits[k]); if (bits[k]) { expected = expected.setBit(k); } } Assert.assertEquals(expected, b.toBigInteger()); BitVector revived = factory.apply(j); revived.copyFrom(expected); Assert.assertEquals(b, revived); } }
From source file:io.syndesis.model.integration.IntegrationRevision.java
public static IntegrationRevision deployedRevision(Integration integration) { BigInteger totalTimesUsed = integration.getTimesUsed().orElse(BigInteger.ZERO); BigInteger parentUses = integration.getRevisions().stream() .map(i -> i.getTimesUsed().orElse(BigInteger.ZERO)).reduce((n1, n2) -> n1.add(n2)) .orElse(BigInteger.ZERO); return new IntegrationRevision.Builder() .createFrom(integration.getDeployedRevision() .orElseGet(() -> IntegrationRevision.createNewRevision(integration))) .timesUsed(Optional.of(totalTimesUsed.subtract(parentUses))).lastUpdated(new Date()).build(); }