Java Decimal decimalDigit(final long value, final int i)

Here you can find the source of decimalDigit(final long value, final int i)

Description

Return a particular digit value from a given number

License

Apache License

Parameter

Parameter Description
value The source to retrieve the digit
i The place to retreive

Return

The digit value

Declaration

public static int decimalDigit(final long value, final int i) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**// w  ww  .  j a  v  a 2s .  c om
     * Return a particular digit value from a given number
     * @param value The source to retrieve the digit
     * @param i The place to retreive
     * @return The digit value
     */
    public static int decimalDigit(final long value, final int i) {
        int result = (int) (Math.abs(value) % Math.pow(10, i));
        if (i > 1) {
            result /= Math.pow(10, i - 1);
        }
        return result;
    }
}

Related

  1. decimalAlign(int width, int precision, String s)
  2. decimalDigitCount(int num)
  3. decimalDump(final byte[] bytes)
  4. decimalPart(float f)
  5. decimalPart(float number)