当前位置: 首页>>代码示例>>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;未经允许,请勿转载。