How in Java do you return the first digit of an integer.?
i.e.
345
Returns an int of 3.
Yet another way:
public int firstDigit(int x) { if (x == 0) return 0; x = Math.abs(x); return (int) Math.floor(x / Math.pow(10, Math.floor(Math.log10(x)))); }