Java BigDeciaml Decode decodeRealNumberRange(String value, BigDecimal offsetValue)

Here you can find the source of decodeRealNumberRange(String value, BigDecimal offsetValue)

Description

decode Real Number Range

License

Apache License

Declaration

public static BigDecimal decodeRealNumberRange(String value, BigDecimal offsetValue) 

Method Source Code

//package com.java2s;
/**// ww  w  .java2  s .c  om
 * *****************************************************************************
 * Copyright 2007 Amazon Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License");
 *
 * You may not use this file except in compliance with the License. You may obtain a copy of the License at: http://aws.amazon.com/apache2.0 This file is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 * ***************************************************************************** __ _ _ ___ ( )( \/\/ )/ __) /__\ \ / \__ \ (_)(_) \/\/ (___/
 *
 * Amazon Simple DB Java Library API Version: 2007-11-07 Generated: Fri Jan 18 01:13:17 PST 2008
 *
 */

import java.math.BigDecimal;

public class Main {
    private static final int BASE = 10;

    public static BigDecimal decodeRealNumberRange(String value, BigDecimal offsetValue) {
        BigDecimal offsetNumber = new BigDecimal(value);
        return (offsetNumber.subtract(offsetValue));
    }

    public static BigDecimal decodeRealNumberRange(String value, int maxDigitsRight, BigDecimal offsetValue) {
        BigDecimal offsetNumber = new BigDecimal(value);
        BigDecimal shiftMultiplier = new BigDecimal(Math.pow(BASE, maxDigitsRight));
        BigDecimal tempVal0 = offsetValue.multiply(shiftMultiplier);
        BigDecimal tempVal = (offsetNumber.subtract(tempVal0));
        return (tempVal.divide(shiftMultiplier));
    }
}