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


Java BigDecimal.intValue方法代码示例

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


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

示例1: decode

import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
public YearMonth decode(
        BsonReader reader,
        DecoderContext decoderContext) {

    BigDecimal value = reader
            .readDecimal128()
            .bigDecimalValue();
    int year = value.intValue();
    return of(
            year,
            value.subtract(new BigDecimal(year))
                 .scaleByPowerOfTen(2)
                 .abs()
                 .intValue()
    );
}
 
开发者ID:cbartosiak,项目名称:bson-codecs-jsr310,代码行数:18,代码来源:YearMonthCodec.java

示例2: bigDecimalToString

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Return the string encoded in a BigDecimal.
 * Repeatedly multiply the input value by 65536; the integer portion after such a multiplication
 * represents a single character in base 65536. Convert that back into a char and create a
 * string out of these until we have no data left.
 */
String bigDecimalToString(BigDecimal bd) {
  BigDecimal cur = bd.stripTrailingZeros();
  StringBuilder sb = new StringBuilder();

  for (int numConverted = 0; numConverted < MAX_CHARS; numConverted++) {
    cur = cur.multiply(ONE_PLACE);
    int curCodePoint = cur.intValue();
    if (0 == curCodePoint) {
      break;
    }

    cur = cur.subtract(new BigDecimal(curCodePoint));
    sb.append(Character.toChars(curCodePoint));
  }

  return sb.toString();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TextSplitter.java

示例3: countProgress

import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Integer countProgress(Integer totalStep, Integer actualStep) {
    if (totalStep == null || totalStep <= 0) {
        totalStep = Integer.MAX_VALUE;
    }
    if (actualStep == null || actualStep <= 0) {
        actualStep = 0;
    }

    if (actualStep > totalStep) {
        actualStep = totalStep - 1;
    }
    BigDecimal step = new BigDecimal(100);
    BigDecimal divider = new BigDecimal(totalStep);
    step = step.divide(divider, totalStep.toString().length(), RoundingMode.HALF_UP);
    step = step.multiply(new BigDecimal(actualStep));
    return step.intValue();
}
 
开发者ID:jmd-stuff,项目名称:task-app,代码行数:20,代码来源:TaskAppServiceImpl.java

示例4: setPhoneBrightness

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Sets the brightness for the activity supplied as well as the system
 * brightness level. The brightness value passed in should be an integer
 * between 0 and 100. This method will translate that number into a normalized
 * value using the devices actual maximum brightness level and the minimum
 * brightness level calibrated via the CalibrateActivity activity.
 * 
 * @param resolver
 *          The ContentResolver.
 * @param window
 *          The activity Window.
 * @param brightnessPercentage
 *          An integer between 0 and 100.
 */
static void setPhoneBrightness(ContentResolver resolver,
    Window window,
    DbAccessor db,
    int brightnessPercentage) {
  // Lookup the minimum acceptable brightness set by the CalibrationActivity.
  int min_value = db.getMinimumBrightness();

  // Convert the normalized application brightness to a system value (between
  // min_value and 255).
  BigDecimal d = new BigDecimal((brightnessPercentage / 100.0)
      * (255 - min_value) + min_value);
  d = d.setScale(0, BigDecimal.ROUND_HALF_EVEN);
  int brightnessUnits = d.intValue();

  if (brightnessUnits < min_value) {
    brightnessUnits = min_value;
  } else if (brightnessUnits > 255) {
    brightnessUnits = 255;
  }
  setSystemBrightness(resolver, brightnessUnits);
  setActivityBrightness(window, brightnessUnits);
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:37,代码来源:Util.java

示例5: bigDecimalToString_num

import java.math.BigDecimal; //导入方法依赖的package包/类
public String bigDecimalToString_num(BigDecimal bd) {
    BigDecimal cur = bd.stripTrailingZeros();
    StringBuilder sb = new StringBuilder();

    for (int numConverted = 0; numConverted < NUM_MAX_CHARS; numConverted++) {
        cur = cur.multiply(NUM_ONE_PLACE);
        int code = cur.intValue();

        cur = cur.subtract(new BigDecimal(code));
        int ch = numCodeToChar(code);
        sb.append((char) ch);
    }

    return sb.toString();
}
 
开发者ID:BriData,项目名称:DBus,代码行数:16,代码来源:TextSplitter.java

示例6: getPhoneBrighness

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Calculates the current application-defined brightness value of the phone.
 * This is done by taking the actual system brightness (a value from 0 to 255)
 * and normalizing it to a scale of 0 to 100. The actual brightness percentage
 * is calculated on the scale of minimumBrightness to 255, though.
 * 
 * @param resolver
 *          The ContentResolver.
 * @param db
 *          A database accessor pointing to a DB with the minimum
 *          brightness setting in it.
 * @return A value between 0 and 100.
 */
static int getPhoneBrighness(ContentResolver resolver, DbAccessor db) {
  int systemBrightness = getSystemBrightness(resolver);
  int minValue = db.getMinimumBrightness();

  // The system brightness can range from 0 to 255. To normalize this
  // to the application's 0 to 100 brightness values, we lookup the
  // configured minimum value and then normalize for the range
  // minValue to 255.
  BigDecimal d = new BigDecimal((systemBrightness - minValue)
      / (255.0 - minValue) * 100.0);
  d = d.setScale(0, BigDecimal.ROUND_HALF_EVEN);
  int normalizedBrightness = d.intValue();

  if (normalizedBrightness < 0) {
    // This can happen if another application sets the phone's brightness
    // to a value lower than our configured minimum.
    return 0;
  } else {
    return normalizedBrightness;
  }
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:35,代码来源:Util.java

示例7: doLastOp

import java.math.BigDecimal; //导入方法依赖的package包/类
private void doLastOp() {
    isRestart = true;
    if (lastOp == '\0' || stack.size() == 1) {
        return;
    }

    String valTwo = stack.pop();
    String valOne = stack.pop();
    switch (lastOp) {
        case '+':
            stack.push(new BigDecimal(valOne).add(new BigDecimal(valTwo)).toPlainString());
            break;
        case '-':
            stack.push(new BigDecimal(valOne).subtract(new BigDecimal(valTwo)).toPlainString());
            break;
        case '*':
            stack.push(new BigDecimal(valOne).multiply(new BigDecimal(valTwo)).toPlainString());
            break;
        case '/':
            BigDecimal d2 = new BigDecimal(valTwo);
            if (d2.intValue() == 0) {
                stack.push("0.0");
            } else {
                stack.push(new BigDecimal(valOne).divide(d2, 2, BigDecimal.ROUND_HALF_UP).toPlainString());
            }
            break;
        default:
            break;
    }
    setDisplay(stack.peek());
    if (isInEquals) {
        stack.push(valTwo);
    }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:35,代码来源:CalculatorInput.java

示例8: substraction

import java.math.BigDecimal; //导入方法依赖的package包/类
@Bind
public long substraction() {
	Injector inj = getInjector();
	Integer intNum = inj.get(Integer.class);
	String strNum = inj.get(String.class);
	BigDecimal bdNum = inj.get(BigDecimal.class);
	return intNum - new Integer(strNum) - bdNum.intValue();
}
 
开发者ID:cr3ativ3,项目名称:Fluf,代码行数:9,代码来源:InheritanceTests.java

示例9: addition

import java.math.BigDecimal; //导入方法依赖的package包/类
@Bind
@Override
public long addition(int value) {
	Injector inj = getInjector();
	Integer intNum = inj.get(Integer.class);
	String strNum = inj.get(String.class);
	BigDecimal bdNum = inj.get(BigDecimal.class);
	return value + intNum + new Integer(strNum) + bdNum.intValue();
}
 
开发者ID:cr3ativ3,项目名称:Fluf,代码行数:10,代码来源:BasicTests.java

示例10: lexDigit

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * 数値定数の字句解析を行います。
 * @throws Exception 小数型定数の記述中に、複数個の小数点が発見された場合に例外を発生させます。
 */
private void lexDigit() throws Exception {
    BigDecimal num = new BigDecimal("0");
    boolean point = false; // 小数かどうか
    int decimal_place = 0; // 小数第何位に達しているか
    while (true) {
        int c = reader.read();
        if (c < 0) break;
        if (!Character.isDigit((char)c) && c != '.') {
            reader.unread();
            if (decimal_place == 0 && point) {
                reader.unread();
                tokenType = INT;
            }
            break;
        }
        if (c == '.' && point) {
            reader.unread(decimal_place);
            tokenType = DOUBLE;
            break;
        }
        if (c == '.') point = true; // はじめて小数点が登場したので val に DoubleType を代入するように設定
        if (point && c != '.') {
            decimal_place++;
            num = num.add(new BigDecimal(c - '0').multiply(new BigDecimal("0.1").pow(decimal_place)));
        } else if (c != '.') {
            num = num.multiply(new BigDecimal("10")).add(new BigDecimal(c - '0'));
        }
    }
    if (decimal_place != 0) {
        val = new Double(line, num.doubleValue());
    } else {
        val = new Int(line, num.intValue()); // 整数だったのでint型にキャストしてから Integer を代入
    }
}
 
开发者ID:xemime-lang,项目名称:xemime,代码行数:39,代码来源:Lexer.java

示例11: execute

import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
public Object execute(List<ExpressionData<?>> dataList, Context context,Cell currentCell) {
	int feed=0;
	if(dataList.size()>0){
		BigDecimal data=buildBigDecimal(dataList);
		feed=data.intValue();
	}
	if(feed==0){
		return Math.random();
	}
	return RandomUtils.nextInt(feed);
}
 
开发者ID:youseries,项目名称:ureport,代码行数:13,代码来源:RandomFunction.java

示例12: convertToInt

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Converter from a numeric object to Integer. Input is checked to be
 * within range represented by the given number type.
 */
static Integer convertToInt(SessionInterface session, Object a, int type) {

    int value;

    if (a instanceof Integer) {
        if (type == Types.SQL_INTEGER) {
            return (Integer) a;
        }

        value = ((Integer) a).intValue();
    } else if (a instanceof Long) {
        long temp = ((Long) a).longValue();

        if (Integer.MAX_VALUE < temp || temp < Integer.MIN_VALUE) {
            throw Error.error(ErrorCode.X_22003);
        }

        value = (int) temp;
    } else if (a instanceof BigDecimal) {
        BigDecimal bd = ((BigDecimal) a);

        if (bd.compareTo(MAX_INT) > 0 || bd.compareTo(MIN_INT) < 0) {
            throw Error.error(ErrorCode.X_22003);
        }

        value = bd.intValue();
    } else if (a instanceof Double || a instanceof Float) {
        double d = ((Number) a).doubleValue();

        if (session instanceof Session) {
            if (!((Session) session).database.sqlConvertTruncate) {
                d = java.lang.Math.rint(d);
            }
        }

        if (Double.isInfinite(d) || Double.isNaN(d)
                || d >= (double) Integer.MAX_VALUE + 1
                || d <= (double) Integer.MIN_VALUE - 1) {
            throw Error.error(ErrorCode.X_22003);
        }

        value = (int) d;
    } else {
        throw Error.error(ErrorCode.X_42561);
    }

    if (type == Types.TINYINT) {
        if (Byte.MAX_VALUE < value || value < Byte.MIN_VALUE) {
            throw Error.error(ErrorCode.X_22003);
        }
    } else if (type == Types.SQL_SMALLINT) {
        if (Short.MAX_VALUE < value || value < Short.MIN_VALUE) {
            throw Error.error(ErrorCode.X_22003);
        }
    }

    return Integer.valueOf(value);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:63,代码来源:NumberType.java

示例13: convertToInt

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Converter from a numeric object to Integer. Input is checked to be
 * within range represented by the given number type.
 */
static Integer convertToInt(Object a, int type) {

    int value;

    if (a instanceof Integer) {
        if (type == Types.SQL_INTEGER) {
            return (Integer) a;
        }

        value = ((Integer) a).intValue();
    } else if (a instanceof Long) {
        long temp = ((Long) a).longValue();

        if (Integer.MAX_VALUE < temp || temp < Integer.MIN_VALUE) {
            throw Error.error(ErrorCode.X_22003);
        }

        value = (int) temp;
    } else if (a instanceof BigDecimal) {
        BigDecimal bd = ((BigDecimal) a);

        if (bd.compareTo(MAX_INT) > 0 || bd.compareTo(MIN_INT) < 0) {
            throw Error.error(ErrorCode.X_22003);
        }

        value = bd.intValue();
    } else if (a instanceof Double || a instanceof Float) {
        double d = ((Number) a).doubleValue();

        if (Double.isInfinite(d) || Double.isNaN(d)
                || d >= (double) Integer.MAX_VALUE + 1
                || d <= (double) Integer.MIN_VALUE - 1) {
            throw Error.error(ErrorCode.X_22003);
        }

        value = (int) d;
    } else {
        throw Error.error(ErrorCode.X_42561);
    }

    if (type == Types.TINYINT) {
        if (Byte.MAX_VALUE < value || value < Byte.MIN_VALUE) {
            throw Error.error(ErrorCode.X_22003);
        }
    } else if (type == Types.SQL_SMALLINT) {
        if (Short.MAX_VALUE < value || value < Short.MIN_VALUE) {
            throw Error.error(ErrorCode.X_22003);
        }
    }

    return ValuePool.getInt(value);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:57,代码来源:NumberType.java

示例14: toInteger

import java.math.BigDecimal; //导入方法依赖的package包/类
private Integer toInteger(Object obj) throws SQLException {
    BigDecimal val = (BigDecimal) obj;
    return val != null ? val.intValue() : null;
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:5,代码来源:OracleDeployIT.java

示例15: getTimeout

import java.math.BigDecimal; //导入方法依赖的package包/类
private int getTimeout(final ZMoteConfig config) {
    final BigDecimal timeout = config.getTimeout();
    return (timeout != null) ? timeout.intValue() : ZMoteBindingConstants.DEFAULT_TIMEOUT;
}
 
开发者ID:alexmaret,项目名称:openhab-binding-zmote,代码行数:5,代码来源:ZMoteService.java


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