Here you can find the source of pow10(final int exponent)
Parameter | Description |
---|---|
exponent | the exponent of the base. Cannot exceed 18. |
10^exponent
public static long pow10(final int exponent)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w . ja v a 2s . c o m*/ * Powers of ten as long values 10^0; 10^1; 10^2 ...10^18. */ private static final long[] POWER10 = new long[] { 1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L, 1000000000L, 10000000000L, 100000000000L, 1000000000000L, 10000000000000L, 100000000000000L, 1000000000000000L, 10000000000000000L, 100000000000000000L, 1000000000000000000L }; /** * A very efficient function to compute powers of 10. * <p> * Since a long is a signed 64 bit two's-complement number, its range is * <code>-9,223,372,036,854,775,808</code> to <code>9,223,372,036,854,775,807</code>. * Thus, <code>10^18 < 9,223,372,036,854,775,807 < 10^19</code>. * <p> * <b>Precondition</b>: <code>0 <= exponent <= 18 </code> * * @param exponent the exponent of the base. Cannot exceed 18. * @return the value <code>10^exponent</code> */ public static long pow10(final int exponent) { return POWER10[exponent]; } }