當前位置: 首頁>>代碼示例>>Java>>正文


Java BigDecimal.toBigInteger方法代碼示例

本文整理匯總了Java中java.math.BigDecimal.toBigInteger方法的典型用法代碼示例。如果您正苦於以下問題:Java BigDecimal.toBigInteger方法的具體用法?Java BigDecimal.toBigInteger怎麽用?Java BigDecimal.toBigInteger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.math.BigDecimal的用法示例。


在下文中一共展示了BigDecimal.toBigInteger方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBinary

import java.math.BigDecimal; //導入方法依賴的package包/類
String getBinary(BigDecimal fl) throws Exception{
BigInteger fi = fl.toBigInteger();
BigInteger rm;
String response="";
while(fi.compareTo(toDeno)>=0){
 rm=fi.remainder(toDeno);
 if(rm.compareTo(BigInteger.ZERO)==0)
    response='0'+","+response;
 else
    response=rm.toString()+","+response;
 fi=fi.subtract(rm).divide(toDeno);
}
response  = fi.toString()+","+response;
if(response.endsWith(","))
 response=response.substring(0,response.length()-1);

return response;
}
 
開發者ID:mathhobbit,項目名稱:EditCalculateAndChart,代碼行數:19,代碼來源:CalCpowb.java

示例2: getBinary

import java.math.BigDecimal; //導入方法依賴的package包/類
String getBinary(BigDecimal fl) throws Exception{
BigInteger fi = fl.toBigInteger();
BigInteger rm;
String response="";
while(fi.compareTo(tWO)>=0){
 rm=fi.remainder(tWO);
 if(rm.compareTo(BigInteger.ZERO)==0)
    response='0'+response;
 else
    response='1'+response;
 fi=fi.subtract(rm).divide(tWO);
} 
int precisionCorrection=(response.length()-response.length()%10)/10;
localMC=new MathContext(jc.MC.getPrecision()+precisionCorrection,jc.MC.getRoundingMode());
return fi.toString()+response;
}
 
開發者ID:mathhobbit,項目名稱:EditCalculateAndChart,代碼行數:17,代碼來源:CalCln.java

示例3: intOp

import java.math.BigDecimal; //導入方法依賴的package包/類
@Override
public BigInteger intOp() {
    BigInteger result;
    Item.ItemResult i = args.get(0).resultType();
    if (i == Item.ItemResult.INT_RESULT) {
        result = args.get(0).valInt();
        nullValue = args.get(0).isNullValue();

    } else if (i == Item.ItemResult.DECIMAL_RESULT) {
        BigDecimal dec = decimalOp();
        if (dec == null)
            result = BigInteger.ZERO;
        else
            result = dec.toBigInteger();
    } else {
        result = realOp().toBigInteger();
    }
    return result;
}
 
開發者ID:actiontech,項目名稱:dble,代碼行數:20,代碼來源:ItemFuncCeiling.java

示例4: intOp

import java.math.BigDecimal; //導入方法依賴的package包/類
@Override
public BigInteger intOp() {
    BigInteger result;
    ItemResult i = args.get(0).resultType();
    if (i == ItemResult.INT_RESULT) {
        result = args.get(0).valInt();
        nullValue = args.get(0).isNullValue();

    } else if (i == ItemResult.DECIMAL_RESULT) {
        BigDecimal dec = decimalOp();
        if (dec == null)
            result = BigInteger.ZERO;
        else
            result = dec.toBigInteger();
    } else {
        result = realOp().toBigInteger();
    }
    return result;
}
 
開發者ID:actiontech,項目名稱:dble,代碼行數:20,代碼來源:ItemFuncFloor.java

示例5: createNew

import java.math.BigDecimal; //導入方法依賴的package包/類
private TransactionFormData createNew(TransactionFormData formData) {
  String fromAddress = formData.getFrom().getValue();
  String fromPassword = BEANS.get(IAccountService.class).getPassword(fromAddress);
  Account from = BEANS.get(EthereumService.class).getWallet(fromAddress, fromPassword);
  String to = formData.getTo().getValue();
  BigInteger amountWei = convertToWei(formData.getAmount().getValue());
  String data = formData.getData().getValue();

  BigDecimal n = formData.getNonce().getValue();
  BigDecimal gp = formData.getGasPrice().getValue();
  BigDecimal gl = formData.getGasLimit().getValue();

  BigInteger nonce = n == null ? null : n.toBigInteger();
  BigInteger gasPrice = gp == null ? null : gp.toBigInteger();
  BigInteger gasLimit = gl == null ? null : gl.toBigInteger();

  BEANS.get(EthereumService.class).createTransaction(from, to, amountWei, data, nonce, gasPrice, gasLimit);

  return formData;
}
 
開發者ID:BSI-Business-Systems-Integration-AG,項目名稱:trading-network,代碼行數:21,代碼來源:TransactionService.java

示例6: decodeText

import java.math.BigDecimal; //導入方法依賴的package包/類
@Override
public Number decodeText(int len, ByteBuf buff) {
  // Todo optimize that
  CharSequence cs = buff.readCharSequence(len, StandardCharsets.UTF_8);
  BigDecimal big = new BigDecimal(cs.toString());
  // julien : that does not seem consistent to either return a Double or BigInteger
  if (big.scale() == 0) {
    return big.toBigInteger();
  } else {
    // we might loose precision here
    return big.doubleValue();
  }
}
 
開發者ID:vietj,項目名稱:reactive-pg-client,代碼行數:14,代碼來源:DataType.java

示例7: baseToSubunit

import java.math.BigDecimal; //導入方法依賴的package包/類
/**
 * Base - taken to mean default unit for a currency e.g. ETH, DOLLARS
 * Subunit - taken to mean subdivision of base e.g. WEI, CENTS
 *
 * @param baseAmountStr - decimal amonut in base unit of a given currency
 * @param decimals - decimal places used to convert to subunits
 * @return amount in subunits
 */
public static BigInteger baseToSubunit(String baseAmountStr, int decimals) {
    assert(decimals >= 0);
    BigDecimal baseAmount = new BigDecimal(baseAmountStr);
    BigDecimal subunitAmount = baseAmount.multiply(BigDecimal.valueOf(10).pow(decimals));
    try {
        return subunitAmount.toBigIntegerExact();
    } catch (ArithmeticException ex) {
        assert(false);
        return subunitAmount.toBigInteger();
    }
}
 
開發者ID:TrustWallet,項目名稱:trust-wallet-android,代碼行數:20,代碼來源:BalanceUtils.java

示例8: valInt

import java.math.BigDecimal; //導入方法依賴的package包/類
@Override
public BigInteger valInt() {
    if (hybridType == ItemResult.DECIMAL_RESULT) {
        BigDecimal val = decimalOp();
        if (val == null)
            return BigInteger.ZERO;
        return val.toBigInteger();
    } else if (hybridType == ItemResult.INT_RESULT) {
        return intOp();
    } else if (hybridType == ItemResult.REAL_RESULT) {
        return realOp().toBigInteger();
    } else if (hybridType == ItemResult.STRING_RESULT) {
        FieldTypes i = fieldType();
        if (i == FieldTypes.MYSQL_TYPE_DATE) {
            return new BigDecimal(valIntFromDate()).toBigInteger();
        } else if (i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_TIMESTAMP) {
            return new BigDecimal(valIntFromDatetime()).toBigInteger();
        } else if (i == FieldTypes.MYSQL_TYPE_TIME) {
            return new BigDecimal(valIntFromTime()).toBigInteger();
        }
        String res = strOp();
        if (res == null)
            return BigInteger.ZERO;
        try {
            return new BigInteger(res);
        } catch (Exception e) {
            LOGGER.info(res + " to BigInteger error!", e);
        }
    }
    return BigInteger.ZERO;
}
 
開發者ID:actiontech,項目名稱:dble,代碼行數:32,代碼來源:ItemFuncNumhybrid.java

示例9: valInt

import java.math.BigDecimal; //導入方法依賴的package包/類
@Override
public BigInteger valInt() {
    BigDecimal tmp = valDecimal();
    if (nullValue)
        return BigInteger.ZERO;
    return tmp.toBigInteger();
}
 
開發者ID:actiontech,項目名稱:dble,代碼行數:8,代碼來源:ItemDecimalTypecast.java

示例10: getDecimalRound

import java.math.BigDecimal; //導入方法依賴的package包/類
private BigDecimal getDecimalRound(BigDecimal value, int round) {
    String sVal = value.toString();
    if (!sVal.contains(".") || round < 0) {
        BigInteger bi = value.toBigInteger();
        return new BigDecimal(getIntRound(bi, round));
    } else {
        return value.setScale(round, RoundingMode.FLOOR);
    }
}
 
開發者ID:actiontech,項目名稱:dble,代碼行數:10,代碼來源:ItemFuncRoundOrTruncate.java

示例11: valInt

import java.math.BigDecimal; //導入方法依賴的package包/類
@Override
public BigInteger valInt() {
    /*
     * Perform division using DECIMAL math if either of the operands has a
     * non-integer type
     */
    if (args.get(0).resultType() != ItemResult.INT_RESULT ||
            args.get(1).resultType() != ItemResult.INT_RESULT) {
        BigDecimal val0p = args.get(0).valDecimal();
        if (args.get(0).isNull())
            return BigInteger.ZERO;
        BigDecimal val1p = args.get(1).valDecimal();
        if (args.get(1).isNull())
            return BigInteger.ZERO;
        try {
            BigDecimal result = val0p.divideToIntegralValue(val1p);
            return result.toBigInteger();
        } catch (ArithmeticException ae) {
            return BigInteger.ZERO;
        }
    } else {
        BigInteger val0 = args.get(0).valInt();
        BigInteger val1 = args.get(1).valInt();
        if (args.get(0).isNull() || args.get(1).isNull())
            return BigInteger.ZERO;
        if (val1.equals(BigInteger.ZERO)) {
            signalDivideByNull();
            return BigInteger.ZERO;
        }
        return val0.divide(val1);
    }
}
 
開發者ID:actiontech,項目名稱:dble,代碼行數:33,代碼來源:ItemFuncIntDiv.java

示例12: castToBigInteger

import java.math.BigDecimal; //導入方法依賴的package包/類
public static BigInteger castToBigInteger(double d)
{
	BigDecimal deci = new BigDecimal( d );
	return deci.toBigInteger();
}
 
開發者ID:CenPC434,項目名稱:java-tools,代碼行數:6,代碼來源:CoreTypes.java

示例13: toInt

import java.math.BigDecimal; //導入方法依賴的package包/類
@Override
public BigInteger toInt(BigDecimal arg) {
    return arg.toBigInteger();
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:5,代碼來源:BigRealAlgebra.java

示例14: getNullableResult

import java.math.BigDecimal; //導入方法依賴的package包/類
@Override
public BigInteger getNullableResult(ResultSet rs, String columnName) throws SQLException {
	BigDecimal bigDecimal = rs.getBigDecimal(columnName);
	return bigDecimal == null ? null : bigDecimal.toBigInteger();
}
 
開發者ID:xsonorg,項目名稱:tangyuan2,代碼行數:6,代碼來源:BigIntegerTypeHandler.java

示例15: toWei

import java.math.BigDecimal; //導入方法依賴的package包/類
public static BigInteger toWei(BigDecimal number, Unit unit) {
    BigDecimal weiFactor = unit.getWeiFactor();
    BigDecimal multiply = weiFactor.multiply(number);

    return multiply.toBigInteger();
}
 
開發者ID:SlotNSlot,項目名稱:SlotNSlot_Android,代碼行數:7,代碼來源:Convert.java


注:本文中的java.math.BigDecimal.toBigInteger方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。