Java BigDecimal readBigDecimal(byte valueBytes[], int valueLength, int scale)

Here you can find the source of readBigDecimal(byte valueBytes[], int valueLength, int scale)

Description

read Big Decimal

License

Open Source License

Declaration

static BigDecimal readBigDecimal(byte valueBytes[], int valueLength,
            int scale) 

Method Source Code

//package com.java2s;
/*/*w  w  w.  jav a  2  s  . c o m*/
 * Microsoft JDBC Driver for SQL Server
 * 
 * Copyright(c) Microsoft Corporation All rights reserved.
 * 
 * This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information.
 */

import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    static BigDecimal readBigDecimal(byte valueBytes[], int valueLength,
            int scale) {
        int sign = (0 == valueBytes[0]) ? -1 : 1;
        byte[] magnitude = new byte[valueLength - 1];
        for (int i = 1; i <= magnitude.length; i++)
            magnitude[magnitude.length - i] = valueBytes[i];
        return new BigDecimal(new BigInteger(sign, magnitude), scale);
    }
}

Related

  1. printGainHTML(BigDecimal gain)
  2. putBigDecimal(byte[] bytes, int offset, BigDecimal val)
  3. randomBigDecimal()
  4. randomBigDecimalList(BigDecimal min, BigDecimal max, int minLength, int maxLength)
  5. rangedValue(BigDecimal lower, BigDecimal upper, Random random)
  6. readBigDecimal(DataInput in)
  7. readBigDecimal(final Object object)
  8. releaseNull(BigDecimal amount)
  9. removeTrailingZeros(final BigDecimal bd)