当前位置: 首页>>代码示例>>Java>>正文


Java BigInteger.doubleValue方法代码示例

本文整理汇总了Java中java.math.BigInteger.doubleValue方法的典型用法代码示例。如果您正苦于以下问题:Java BigInteger.doubleValue方法的具体用法?Java BigInteger.doubleValue怎么用?Java BigInteger.doubleValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.math.BigInteger的用法示例。


在下文中一共展示了BigInteger.doubleValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: nRoot

import java.math.BigInteger; //导入方法依赖的package包/类
/**
 * Returns the Nth root implemented by the formula from <a href="https://en.wikipedia.org/wiki/Nth_root"> wikipedia</a>.
 * 
 * @author AdamKuba
 * @param n degree
 * @param a radicand
 * @return nth root of the radicand
 */
public static BigDecimal nRoot(BigInteger n, BigDecimal a) {
	boolean signed = false;
	if (n.doubleValue()<0){
		n = n.negate();
		signed = true;
	}
	if(signed && a.doubleValue()<0){
		return new BigDecimal("-1");
	}
	double p = 0.00000000001;
	BigDecimal prev=a;
	BigDecimal next=a.divide(new BigDecimal(n),15, RoundingMode.HALF_UP);
	
	while(abs(prev.subtract(next)).doubleValue()>p){
		prev = next;
		next = (new BigDecimal(n.subtract(new BigInteger("1"))).multiply(prev).add(a.divide(exp(n.subtract(new BigInteger("1")),prev),15, RoundingMode.HALF_UP))).divide(new BigDecimal(n),15, RoundingMode.HALF_UP);
	}
	if (signed) next = new BigDecimal("1").divide(next,15, RoundingMode.HALF_UP);
	next = next.round(new MathContext(10));
	return next;
}
 
开发者ID:kudlav,项目名称:Sifon-Industries,代码行数:30,代码来源:MathLib.java

示例2: convertToOrder

import java.math.BigInteger; //导入方法依赖的package包/类
private Order convertToOrder(List<Type> list) {
  Order order = null;
  if (null != list && list.size() > 0) {
    BigInteger quantity = ((Uint256) list.get(0)).getValue();
    BigInteger price = ((Uint256) list.get(1)).getValue();
    Boolean buy = ((Bool) list.get(2)).getValue();
    String ownerAddress = ((Address) list.get(3)).toString();
    BigInteger dealNr = ((Uint256) list.get(4)).getValue();
    BigInteger extId = ((Uint256) list.get(5)).getValue();
    Order.Type type = Order.Type.BUY;
    if (!buy) {
      type = Order.Type.SELL;
    }
    order = new Order(type, quantity.intValue(), price.doubleValue() / 100, extId.intValue());
    order.setId(dealNr.intValue());
    order.setOwner(ownerAddress);
  }
  return order;
}
 
开发者ID:BSI-Business-Systems-Integration-AG,项目名称:trading-network,代码行数:20,代码来源:OrderBookService.java

示例3: MFPNumeric

import java.math.BigInteger; //导入方法依赖的package包/类
public MFPNumeric(BigInteger bigIntValue)   {
    mlValue = bigIntValue.longValue();
    int nComparelValue = bigIntValue.compareTo(BigInteger.valueOf(mlValue));
    if (nComparelValue > 0)    {
        mlValue = Long.MAX_VALUE;   // means long overflowed.
    } else if (nComparelValue < 0)    {
        mlValue = Long.MIN_VALUE;   // means long overflowed.
    }
    mdValue = bigIntValue.doubleValue();
    mbigIntegerValue = bigIntValue;
    mbigDecimalValue = new BigDecimal(bigIntValue);
    mType = Type.MFP_INTEGER_VALUE;
    
    // now let's check if this MFPNumeric is an integer and compare it with 0.
    mbIsActuallyInteger = true;
    mdActualValueCompZero = bigIntValue.compareTo(BigInteger.ZERO);
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:18,代码来源:MFPNumeric.java

示例4: transform

import java.math.BigInteger; //导入方法依赖的package包/类
public String transform(PropertyValue value, String result) {
	double floatValue;
	
	if (value.getLSB() != null) {
		BigInteger val = parse(value, result);
		
		if (!value.mask().equals(BigInteger.ZERO))
			val = val.and(value.mask()); 
		
		if (!value.shift().equals(0))
			val = val.shiftRight(value.shift());
		
		if (value.getSigned() && val.bitLength()==(value.size()*4)) {
			BigInteger complement = new BigInteger(new String(new char[value.size()]).replace("\0", "F"),16);
			val = val.subtract(complement);
		}
		
		if (!objectCache.getTransformData()) {
			int intValue = val.intValue();
			return String.valueOf(intValue);
		}
		
		floatValue = val.doubleValue();
	} else {
		floatValue = Float.parseFloat(result);
	}
	
	if (!value.base().equals(0))
		floatValue = Math.pow(value.base(), floatValue);
	floatValue = floatValue * value.scale();
	floatValue = floatValue + value.offset();
	
	if (value.getType().toLowerCase().equals("f") || value.getType().toLowerCase().equals("float"))
		return String.valueOf(floatValue);
	return String.valueOf(Math.round(floatValue));
}
 
开发者ID:edgexfoundry,项目名称:device-modbus,代码行数:37,代码来源:ObjectTransform.java

示例5: TODO

import java.math.BigInteger; //导入方法依赖的package包/类
@AndroidIncompatible // TODO(cpovirk): File bug for BigDecimal.doubleValue().
public void testBigToDouble() {
  for (BigInteger b : ALL_BIGINTEGER_CANDIDATES) {
    if (b.doubleValue() != DoubleUtils.bigToDouble(b)) {
      failFormat(
          "Converting %s to double: expected doubleValue %s but got bigToDouble %s",
          b,
          b.doubleValue(),
          DoubleUtils.bigToDouble(b));
    }
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:13,代码来源:DoubleUtilsTest.java

示例6: testDoubleValue

import java.math.BigInteger; //导入方法依赖的package包/类
public static int testDoubleValue() {
    int failures = 0;
    for (BigInteger big : ALL_BIGINTEGER_CANDIDATES) {
        double expected = Double.parseDouble(big.toString());
        double actual = big.doubleValue();

        // should be bitwise identical
        if (Double.doubleToRawLongBits(expected) != Double
                .doubleToRawLongBits(actual)) {
            System.out.println(big);
            failures++;
        }
    }
    return failures;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:PrimitiveConversionTests.java

示例7: getNativeDouble

import java.math.BigInteger; //导入方法依赖的package包/类
/**
 * Get the value of a column in the current row as a Java double.
 * 
 * @param columnIndex
 *            the first column is 1, the second is 2,...
 * 
 * @return the column value; 0 if SQL NULL
 * 
 * @exception SQLException
 *                if a database access error occurs
 */
protected double getNativeDouble(int columnIndex) throws SQLException {
    checkRowPos();
    checkColumnBounds(columnIndex);

    columnIndex--; // / JDBC is 1-based

    if (this.thisRow.isNull(columnIndex)) {
        this.wasNullFlag = true;

        return 0;
    }

    this.wasNullFlag = false;

    Field f = this.fields[columnIndex];

    switch (f.getMysqlType()) {
        case MysqlDefs.FIELD_TYPE_DOUBLE:
            return this.thisRow.getNativeDouble(columnIndex);
        case MysqlDefs.FIELD_TYPE_TINY:
            if (!f.isUnsigned()) {
                return getNativeByte(columnIndex + 1);
            }

            return getNativeShort(columnIndex + 1);
        case MysqlDefs.FIELD_TYPE_SHORT:
        case MysqlDefs.FIELD_TYPE_YEAR:
            if (!f.isUnsigned()) {
                return getNativeShort(columnIndex + 1);
            }

            return getNativeInt(columnIndex + 1);
        case MysqlDefs.FIELD_TYPE_INT24:
        case MysqlDefs.FIELD_TYPE_LONG:
            if (!f.isUnsigned()) {
                return getNativeInt(columnIndex + 1);
            }

            return getNativeLong(columnIndex + 1);
        case MysqlDefs.FIELD_TYPE_LONGLONG:
            long valueAsLong = getNativeLong(columnIndex + 1);

            if (!f.isUnsigned()) {
                return valueAsLong;
            }

            BigInteger asBigInt = convertLongToUlong(valueAsLong);

            // TODO: Check for overflow

            return asBigInt.doubleValue();
        case MysqlDefs.FIELD_TYPE_FLOAT:
            return getNativeFloat(columnIndex + 1);
        case MysqlDefs.FIELD_TYPE_BIT:
            return getNumericRepresentationOfSQLBitType(columnIndex + 1);
        default:
            String stringVal = getNativeString(columnIndex + 1);

            if (this.useUsageAdvisor) {
                issueConversionViaParsingWarning("getDouble()", columnIndex, stringVal, this.fields[columnIndex],
                        new int[] { MysqlDefs.FIELD_TYPE_DOUBLE, MysqlDefs.FIELD_TYPE_TINY, MysqlDefs.FIELD_TYPE_SHORT, MysqlDefs.FIELD_TYPE_LONG,
                                MysqlDefs.FIELD_TYPE_LONGLONG, MysqlDefs.FIELD_TYPE_FLOAT });
            }

            return getDoubleFromString(stringVal, columnIndex + 1);
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:79,代码来源:ResultSetImpl.java

示例8: transform

import java.math.BigInteger; //导入方法依赖的package包/类
public String transform(PropertyValue value, String result) {
  double floatValue;
  if (value.getType().toLowerCase().equals("s")
      || value.getType().toLowerCase().equals("string")) {
    return result;
  }

  if (value.getLSB() != null) {
    BigInteger val = parse(value, result);

    if (!value.mask().equals(BigInteger.ZERO)) {
      val = val.and(value.mask());
    }

    if (!value.shift().equals(0)) {
      val = val.shiftRight(value.shift());
    }

    if (value.getSigned() && val.bitLength() == (value.size() * 4)) {
      BigInteger complement =
          new BigInteger(new String(new char[value.size()]).replace("\0", "F"), 16);
      val = val.subtract(complement);
    }

    if (!objectCache.getTransformData()) {
      int intValue = val.intValue();
      return String.valueOf(intValue);
    }

    floatValue = val.doubleValue();
  } else {
    floatValue = Float.parseFloat(result);
  }

  if (!value.base().equals(0)) {
    floatValue = Math.pow(value.base(), floatValue);
  }

  floatValue = floatValue * value.scale();
  floatValue = floatValue + value.offset();

  if (value.getType().toLowerCase().equals("f")
      || value.getType().toLowerCase().equals("float")) {
    return String.valueOf(floatValue);
  }

  return String.valueOf(Math.round(floatValue));
}
 
开发者ID:mgjeong,项目名称:device-opcua-java,代码行数:49,代码来源:ObjectTransform.java

示例9: getNativeDouble

import java.math.BigInteger; //导入方法依赖的package包/类
/**
 * Get the value of a column in the current row as a Java double.
 * 
 * @param columnIndex
 *            the first column is 1, the second is 2,...
 * 
 * @return the column value; 0 if SQL NULL
 * 
 * @exception SQLException
 *                if a database access error occurs
 */
protected double getNativeDouble(int columnIndex) throws SQLException {
    checkRowPos();
    checkColumnBounds(columnIndex);

    columnIndex--; // / JDBC is 1-based

    if (this.thisRow.isNull(columnIndex)) {
        this.wasNullFlag = true;

        return 0;
    }

    this.wasNullFlag = false;

    Field f = this.fields[columnIndex];

    switch (f.getMysqlType()) {
        case MysqlDefs.FIELD_TYPE_DOUBLE:
            return this.thisRow.getNativeDouble(columnIndex);
        case MysqlDefs.FIELD_TYPE_TINY:
            if (!f.isUnsigned()) {
                return getNativeByte(columnIndex + 1);
            }

            return getNativeShort(columnIndex + 1);
        case MysqlDefs.FIELD_TYPE_SHORT:
        case MysqlDefs.FIELD_TYPE_YEAR:
            if (!f.isUnsigned()) {
                return getNativeShort(columnIndex + 1);
            }

            return getNativeInt(columnIndex + 1);
        case MysqlDefs.FIELD_TYPE_INT24:
        case MysqlDefs.FIELD_TYPE_LONG:
            if (!f.isUnsigned()) {
                return getNativeInt(columnIndex + 1);
            }

            return getNativeLong(columnIndex + 1);
        case MysqlDefs.FIELD_TYPE_LONGLONG:
            long valueAsLong = getNativeLong(columnIndex + 1);

            if (!f.isUnsigned()) {
                return valueAsLong;
            }

            BigInteger asBigInt = convertLongToUlong(valueAsLong);

            // TODO: Check for overflow

            return asBigInt.doubleValue();
        case MysqlDefs.FIELD_TYPE_FLOAT:
            return getNativeFloat(columnIndex + 1);
        case MysqlDefs.FIELD_TYPE_BIT:
            return getNumericRepresentationOfSQLBitType(columnIndex + 1);
        default:
            String stringVal = getNativeString(columnIndex + 1);

            if (this.useUsageAdvisor) {
                issueConversionViaParsingWarning("getDouble()", columnIndex, stringVal, this.fields[columnIndex], new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
                        MysqlDefs.FIELD_TYPE_TINY, MysqlDefs.FIELD_TYPE_SHORT, MysqlDefs.FIELD_TYPE_LONG, MysqlDefs.FIELD_TYPE_LONGLONG,
                        MysqlDefs.FIELD_TYPE_FLOAT });
            }

            return getDoubleFromString(stringVal, columnIndex + 1);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:79,代码来源:ResultSetImpl.java

示例10: transform

import java.math.BigInteger; //导入方法依赖的package包/类
public String transform(PropertyValue value, String result) {
  double floatValue;

  // Do not perform transforms on non-numeric fields
  if (nonNumeric(value)) {
    return result;
  }

  if (value.getLSB() != null) {
    BigInteger val = parse(value, result);

    if (!value.mask().equals(BigInteger.ZERO)) {
      val = val.and(value.mask());
    }

    if (!value.shift().equals(0)) {
      val = val.shiftRight(value.shift());
    }

    if (value.getSigned() && val.bitLength() == (value.size() * 4)) {
      BigInteger complement =
          new BigInteger(new String(new char[value.size()]).replace("\0", "F"), 16);
      val = val.subtract(complement);
    }

    if (!objectCache.getTransformData()) {
      int intValue = val.intValue();
      return String.valueOf(intValue);
    }

    floatValue = val.doubleValue();
  } else {
    floatValue = Float.parseFloat(result);
  }

  if (!value.base().equals(0)) {
    floatValue = Math.pow(value.base(), floatValue);
  }

  floatValue = floatValue * value.scale();
  floatValue = floatValue + value.offset();

  if (value.getType().toLowerCase().equals("f")
      || value.getType().toLowerCase().equals("float")) {
    return String.valueOf(floatValue);
  }

  return String.valueOf(Math.round(floatValue));
}
 
开发者ID:edgexfoundry,项目名称:device-mqtt,代码行数:50,代码来源:ObjectTransform.java

示例11: transform

import java.math.BigInteger; //导入方法依赖的package包/类
public String transform(PropertyValue value, String result) {
  double floatValue;

  if (value.getLSB() != null) {
    BigInteger val = parse(value, result);

    if (!value.mask().equals(BigInteger.ZERO)) {
      val = val.and(value.mask());
    }

    if (!value.shift().equals(0)) {
      val = val.shiftRight(value.shift());
    }

    if (value.getSigned() && val.bitLength() == (value.size() * 4)) {
      BigInteger complement =
          new BigInteger(new String(new char[value.size()]).replace("\0", "F"), 16);
      val = val.subtract(complement);
    }

    if (!objectCache.getTransformData()) {
      int intValue = val.intValue();
      return String.valueOf(intValue);
    }

    floatValue = val.doubleValue();
  } else {
    floatValue = Float.parseFloat(result);
  }

  if (!value.base().equals(0)) {
    floatValue = Math.pow(value.base(), floatValue);
  }

  floatValue = floatValue * value.scale();
  floatValue = floatValue + value.offset();

  if (value.getType().toLowerCase().equals("f")
      || value.getType().toLowerCase().equals("float")) {
    return String.valueOf(floatValue);
  }

  return String.valueOf(Math.round(floatValue));
}
 
开发者ID:edgexfoundry,项目名称:device-bluetooth,代码行数:45,代码来源:ObjectTransform.java

示例12: abs

import java.math.BigInteger; //导入方法依赖的package包/类
/**
 * Returns the Absolute value of integer.
 *
 * @param a number
 * @return number which is always positive
 */
private static BigInteger abs(BigInteger a){
	return (a.doubleValue()<=0) ? new BigInteger("0").subtract(a) : a;
}
 
开发者ID:kudlav,项目名称:Sifon-Industries,代码行数:10,代码来源:MathLib.java


注:本文中的java.math.BigInteger.doubleValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。