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


Java BigDecimal.floatValue方法代码示例

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


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

示例1: updateAcceleration

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Update the acceleration using the velocity and time elapsed.
 *
 * @param location new location
 */
synchronized private void updateAcceleration(Location location) {
    if (location.hasSpeed()) {
        if (!hasVelocity) {
            mVelocity = location.getSpeed();
            mTime = System.currentTimeMillis();
            hasVelocity = true;
        } else {
            float velocity = location.getSpeed();
            long currentTime = System.currentTimeMillis();
            float acceleration = (velocity - mVelocity) / (currentTime - mTime) * 1000;
            BigDecimal accelerationRounded = new BigDecimal(acceleration).setScale(2, BigDecimal.ROUND_HALF_UP);

            mAcceleration = accelerationRounded.floatValue();
            mVelocity = velocity;
            mTime = currentTime;
            hasAcceleration = true;
        }
    }
}
 
开发者ID:w86763777,项目名称:BikeLine,代码行数:25,代码来源:GPSService.java

示例2: RotationRequest

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Create a new rotation request.
 *
 * @param rotation Rotation in degrees. Must be between 0 and 360
 * @param mirror Mirror the image when rotating
 * @throws IllegalArgumentException if the rotation degrees are not between 0 and 360
 */
public RotationRequest(BigDecimal rotation, boolean mirror) throws IllegalArgumentException {
  if (rotation.floatValue() < 0 || rotation.floatValue() > 360) {
    throw new IllegalArgumentException("Rotation must be between 0 and 360");
  }
  this.rotation = rotation;
  this.mirror = mirror;
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:15,代码来源:RotationRequest.java

示例3: round

import java.math.BigDecimal; //导入方法依赖的package包/类
public static float round(float d, int decimalPlace) {
    BigDecimal bd = new BigDecimal(Float.toString(d));
    bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP);
    return bd.floatValue();
}
 
开发者ID:Dentacoin,项目名称:aftercare-app-android,代码行数:6,代码来源:DCUtils.java

示例4: analogStickCalc

import java.math.BigDecimal; //导入方法依赖的package包/类
public void analogStickCalc(int x, int y, int[] x_calc, int[] y_calc) {
    float xF, yF, hori, vert;
    float deadZoneCenter = 0.15f;
    float deadZoneOuter = 0.10f;

    x = Math.max(x_calc[0], Math.min(x_calc[2], x));
    y = Math.max(y_calc[0], Math.min(y_calc[2], y));

    if (x >= x_calc[1]) {
        xF = (float) (x - x_calc[1]) / (float) (x_calc[2] - x_calc[1]);
    } else {
        xF = -((float) (x - x_calc[1]) / (float) (x_calc[0] - x_calc[1]));
    }
    if (y >= y_calc[1]) {
        yF = (float) (y - y_calc[1]) / (float) (y_calc[2] - y_calc[1]);
    } else {
        yF = -((float) (y - y_calc[1]) / (float) (y_calc[0] - y_calc[1]));
    }

    float mag = (float) Math.sqrt(xF * xF + yF * yF);

    if (mag > deadZoneCenter) {
        // scale such that output magnitude is in the range [0.0f, 1.0f]
        float legalRange = 1.0f - deadZoneOuter - deadZoneCenter;
        float normalizedMag = Math.min(1.0f, (mag - deadZoneCenter) / legalRange);
        float scale = normalizedMag / mag;
        hori = xF * scale;
        vert = yF * scale;
    } else {
        // stick is in the inner dead zone
        hori = 0.0f;
        vert = 0.0f;
    }

    BigDecimal bdHori = new BigDecimal(hori);
    bdHori = bdHori.setScale(2, RoundingMode.HALF_EVEN);
    BigDecimal bdVert = new BigDecimal(vert);
    bdVert = bdVert.setScale(2, RoundingMode.HALF_EVEN);

    horizontal = bdHori.floatValue();
    vertical = bdVert.floatValue();
}
 
开发者ID:elgoupil,项目名称:joyconLib,代码行数:43,代码来源:JoyconStickCalc.java

示例5: getBaseValue

import java.math.BigDecimal; //导入方法依赖的package包/类
private double getBaseValue(SRVMBidder bidder, Band band) {
    Preconditions.checkArgument(bidder.getBaseValues().containsKey(band.getName()));
    BigDecimal value = bidder.getBaseValues().get(band.getName());
    return value.floatValue();
}
 
开发者ID:spectrumauctions,项目名称:sats-opt,代码行数:6,代码来源:SRVMBidderPartialMIP.java

示例6: getIntrabandSynergyFactor

import java.math.BigDecimal; //导入方法依赖的package包/类
private double getIntrabandSynergyFactor(SRVMBidder bidder, Band band) {
    Preconditions.checkArgument(bidder.getIntrabandSynergyFactors().containsKey(band.getName()));
    BigDecimal value = bidder.getIntrabandSynergyFactors().get(band.getName());
    return value.floatValue();
}
 
开发者ID:spectrumauctions,项目名称:sats-opt,代码行数:6,代码来源:SRVMBidderPartialMIP.java

示例7: round

import java.math.BigDecimal; //导入方法依赖的package包/类
public static float round(double d, int decimalPlace) {
    BigDecimal bd = new BigDecimal(Double.toString(d));
    bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP);
    return bd.floatValue();
}
 
开发者ID:redmyers,项目名称:484_P7_1-Java,代码行数:6,代码来源:Utils.java

示例8: getReoundedMeasure

import java.math.BigDecimal; //导入方法依赖的package包/类
private float getReoundedMeasure(Float measure, int decimal) {
	BigDecimal bd = new BigDecimal(Float.toString(measure));
	bd = bd.setScale(decimal, BigDecimal.ROUND_HALF_UP);
	return bd.floatValue();
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:6,代码来源:MeasureAreaTool.java

示例9: getReoundedMeasure

import java.math.BigDecimal; //导入方法依赖的package包/类
private float getReoundedMeasure(double measure, int decimal) {
	BigDecimal bd = new BigDecimal(Double.toString(measure));
	bd = bd.setScale(decimal, BigDecimal.ROUND_HALF_UP);
	return bd.floatValue();
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:6,代码来源:RouteVehicleTool.java

示例10: Rounding

import java.math.BigDecimal; //导入方法依赖的package包/类
private static double Rounding(double d) {
    BigDecimal bd = new BigDecimal(d);
    bd.setScale(1, RoundingMode.HALF_UP);
    return bd.floatValue();
}
 
开发者ID:miLLlulei,项目名称:Accessibility,代码行数:6,代码来源:FileUtils.java

示例11: round

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Rounds the {@code inputValue} to specified number of digits to the right of the decimal point.
 * This function rounds the number depending on the "{@code numberOfDigits} + 1" digit.
 *
 * @param inputValue     the double value to be rounded
 * @param numberOfDigits the number of digits to round the {@code inputValue}
 * @return rounded {@code inputValue} value
 */
public static Float round(Float inputValue, int numberOfDigits) {
    if (inputValue == null)
        return null;
    BigDecimal bigDecimal = new BigDecimal(inputValue);
    bigDecimal = bigDecimal.setScale(numberOfDigits, RoundingMode.HALF_UP);
    return bigDecimal.floatValue();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:16,代码来源:NumericFunctions.java

示例12: roundUp

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Rounds the {@code inputValue} to specified number of digits to the right of the decimal point.
 * This function always rounds up the number irrespective of the "{@code numberOfDigits} + 1" digit.
 *
 * @param inputValue     the float value to be rounded up
 * @param numberOfDigits the number of digits to round up the {@code inputValue}
 * @return rounded up {@code inputValue} value
 */
public static Float roundUp(Float inputValue, int numberOfDigits) {
    if (inputValue == null)
        return null;
    BigDecimal bigDecimal = new BigDecimal(inputValue);
    bigDecimal = bigDecimal.setScale(numberOfDigits, BigDecimal.ROUND_UP);
    return bigDecimal.floatValue();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:16,代码来源:NumericFunctions.java

示例13: roundDown

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Rounds the {@code inputValue} to specified number of digits to the right of the decimal point.
 * This function always rounds down the number irrespective of the "{@code numberOfDigits} + 1" digit.
 *
 * @param inputValue     the float value to be rounded down
 * @param numberOfDigits the number of digits to round down the {@code inputValue}
 * @return rounded down {@code inputValue} value
 */
public static Float roundDown(Float inputValue, int numberOfDigits) {
    if (inputValue == null)
        return null;
    BigDecimal bigDecimal = new BigDecimal(inputValue);
    bigDecimal = bigDecimal.setScale(numberOfDigits, BigDecimal.ROUND_DOWN);
    return bigDecimal.floatValue();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:16,代码来源:NumericFunctions.java

示例14: truncate

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Truncates the {@code inputValue} to specified number of digits to the right of the decimal point.
 * If {@code numberOfDigits} is greater than the number of digits to the right of {@code input} then the
 * function returns {@code input} value. It does not add trailing zeros.
 *
 * @param inputValue     the float value to be truncated
 * @param numberOfDigits the number of digits to truncate to the right of the decimal point
 * @return truncated {@code input} value
 */
public static Float truncate(Float inputValue, int numberOfDigits) {
    if (inputValue == null)
        return null;
    BigDecimal bigDecimal = new BigDecimal(inputValue);
    BigDecimal roundedWithScale = bigDecimal.setScale(numberOfDigits, RoundingMode.DOWN).stripTrailingZeros();
    return roundedWithScale.floatValue();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:NumericFunctions.java

示例15: getFloat

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Returns the value of the specified attribute in the current item as a
 * <code>float</code>.
 *
 * @see #isNull(String) #isNull(String) to check if the attribute value is
 *      null.
 * @see #isPresent(String) #isPresent(String) to check if the attribute
 *      value is present.
 *
 * @throws NumberFormatException
 *             if the attribute value is null or not a valid representation
 *             of a {@code BigDecimal}.
 */
public float getFloat(String attrName) {
    BigDecimal bd = getNumber(attrName);
    if (bd == null) {
        throw new NumberFormatException("value of " + attrName + " is null");
    }
    return bd.floatValue();
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:21,代码来源:Item.java


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