Java Number Power pow10(int degree)

Here you can find the source of pow10(int degree)

Description

Adapted from com.devexperts.dxpro.common.util.MathUtils.

License

Open Source License

Parameter

Parameter Description
degree a parameter

Return

pow

Declaration

private static double pow10(int degree) 

Method Source Code

//package com.java2s;
/******************************************************************************************
 The MIT License (MIT)//from  w w w .jav  a2s .co m

 Copyright (c) 2014 Tradable Labs / Tradable ApS
    
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
    
 The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.
    
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
    
 ****************************************************************************************/

public class Main {
    /**
     * Adapted from com.devexperts.dxpro.common.util.MathUtils.
     * 
     * @param degree
     * @return pow
     */
    private static double pow10(int degree) {
        double pow;

        if (degree >= 0) {
            pow = 1;
            for (int i = 0; i < degree; i++) {
                pow *= 10;
            }
        } else {
            pow = 0.1;
            for (int i = -1; i > degree; i--) {
                pow /= 10;
            }
        }
        return pow;
    }
}

Related

  1. pow(long n, long pow)
  2. pow(long value, long pow)
  3. pow(Number x, Number exponent)
  4. pow(String str, int n)
  5. pow10(final int exponent)
  6. pow10(int n)
  7. pow16(float a)
  8. pow2(double base, double power)
  9. pow2(double num)