Examples of divideAndRemainder()


Examples of java.math.BigDecimal.divideAndRemainder()

        reverseCardsForDigit[i] = reverseCardsForDigit[i+1].multiply(colCards[i]);
      }
    }

    for (int i = 0; i < baseDigit; i++) {
      result = value.divideAndRemainder(reverseCardsForDigit[i + 1]);
      incs[i] = result[0];
      value = result[1];
    }
    int finalId = baseDigit;
    incs[finalId] = value;
View Full Code Here

Examples of java.math.BigDecimal.divideAndRemainder()

        reverseCardsForDigit[i] = reverseCardsForDigit[i+1].multiply(colCards[i]);
      }
    }

    for (int i = 0; i < baseDigit; i++) {
      result = value.divideAndRemainder(reverseCardsForDigit[i + 1]);
      incs[i] = result[0];
      value = result[1];
    }
    int finalId = baseDigit;
    incs[finalId] = value;
View Full Code Here

Examples of java.math.BigDecimal.divideAndRemainder()

  public static String durationToXmlFormat( final long _milliseconds )
  {
    try {
      final boolean positive = _milliseconds > 0;
      final BigDecimal seconds = BigDecimal.valueOf( Math.abs( _milliseconds ), 3 );
      final BigDecimal[] minutesAndSeconds = seconds.divideAndRemainder( BigDecimal.valueOf( 60 ) );
      final BigInteger[] hoursAndMinutes = minutesAndSeconds[ 0 ].toBigInteger().divideAndRemainder( BigInteger.valueOf( 60 ) );
      final DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
      final Duration duration = datatypeFactory.newDuration( positive, null, null, null, hoursAndMinutes[ 0 ], hoursAndMinutes[ 1 ], minutesAndSeconds[ 1 ] );
      return duration.toString();
    } catch (DatatypeConfigurationException e) {
View Full Code Here

Examples of java.math.BigDecimal.divideAndRemainder()

    int[] convertToCodeWords(BigInteger encodedData) {
        final BigDecimal div1 = new BigDecimal(636);
        final BigDecimal div2 = new BigDecimal(1365);
        int[] codeWords = new int[10];
        BigDecimal d0 = new BigDecimal(encodedData);
        BigDecimal[] d1 = d0.divideAndRemainder(div1);
        codeWords[9] = d1[1].intValue();
        for (int i = 8; i > 0; i--) {
            d1 = d1[0].divideAndRemainder(div2);
            codeWords[i] = d1[1].intValue();
        }
View Full Code Here

Examples of java.math.BigDecimal.divideAndRemainder()

   
    if(moeda) {
      n = n.setScale(2, BigDecimal.ROUND_HALF_UP);
    }
   
    BigDecimal[] split = n.divideAndRemainder(BigDecimal.ONE);

    // se não houver centavos, só retorna o principal
    if (split[1].compareTo(BigDecimal.ZERO) == 0) {
      return principal(split[0], nomesMoeda);
    }
View Full Code Here

Examples of java.math.BigDecimal.divideAndRemainder()

    if( t.isIntegerOnly() )
      return n;

    if( Type.BIG_DECIMAL.equals( t ) ) {
      final BigDecimal d = (BigDecimal) n;
      final BigDecimal[] dandr = d.divideAndRemainder( BigDecimal.ONE );
      if( dandr[1].equals( BigDecimal.ZERO ) || d.signum() == -1 )
        return shrinkBigInteger( dandr[0].toBigIntegerExact() );
      else
        return shrinkBigInteger( dandr[0].toBigIntegerExact().add( BigInteger.ONE ) );
    }
View Full Code Here

Examples of java.math.BigDecimal.divideAndRemainder()

    if( t.isIntegerOnly() )
      return n;

    if( Type.BIG_DECIMAL.equals( t ) ) {
      final BigDecimal d = (BigDecimal) n;
      final BigDecimal[] dandr = d.divideAndRemainder( BigDecimal.ONE );
      if( dandr[1].equals( BigDecimal.ZERO ) || d.signum() == 1 )
        return shrinkBigInteger( dandr[0].toBigIntegerExact() );
      else
        return shrinkBigInteger( dandr[0].toBigIntegerExact().subtract( BigInteger.ONE ) );
    }
View Full Code Here

Examples of java.math.BigInteger.divideAndRemainder()

        if (sdv.negative) {
            seconds = seconds.negate();
        }
        BigDecimal microseconds = seconds.multiply(DecimalValue.BIG_DECIMAL_ONE_MILLION);
        BigInteger intMicros = microseconds.toBigInteger();
        BigInteger[] parts = intMicros.divideAndRemainder(BigInteger.valueOf(1000000));
        sdv.seconds = parts[0].longValue();
        sdv.microseconds = parts[1].intValue();
        return sdv;
    }
View Full Code Here

Examples of java.math.BigInteger.divideAndRemainder()

            }
            /* mlo/S = maximum acceptable error, divided by 10^k, if the output is less than d. */
            /* mhi/S = maximum acceptable error, divided by 10^k, if the output is greater than d. */

            for(i = 1;;i++) {
                BigInteger[] divResult = b.divideAndRemainder(S);
                b = divResult[1];
                dig = (char)(divResult[0].intValue() + '0');
                /* Do we yet have the shortest decimal string
                 * that will round to d?
                 */
 
View Full Code Here

Examples of java.math.BigInteger.divideAndRemainder()

            }
        }
        else
            for(i = 1;; i++) {
//                (char)(dig = quorem(b,S) + '0');
                BigInteger[] divResult = b.divideAndRemainder(S);
                b = divResult[1];
                dig = (char)(divResult[0].intValue() + '0');
                buf.append(dig);
                if (i >= ilim)
                    break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.