Java Decimal decimalDigitCount(int num)

Here you can find the source of decimalDigitCount(int num)

Description

decimal Digit Count

License

Open Source License

Declaration

public static int decimalDigitCount(int num) 

Method Source Code

//package com.java2s;
/*//from   www . j av a 2  s .  com
 * JBoss, Home of Professional Open Source.
 * Copyright 2014 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * 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://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License 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.
 */

public class Main {
    public static int decimalDigitCount(int num) {
        if (num < 10)
            return 1;
        if (num < 100)
            return 2;
        if (num < 1000)
            return 3;
        if (num < 10000)
            return 4;
        if (num < 100000)
            return 5;
        if (num < 1000000)
            return 6;
        if (num < 10000000)
            return 7;
        if (num < 100000000)
            return 8;
        if (num < 1000000000)
            return 9;
        return 10;
    }
}

Related

  1. decimalAlign(int width, int precision, String s)
  2. decimalDigit(final long value, final int i)
  3. decimalDump(final byte[] bytes)
  4. decimalPart(float f)
  5. decimalPart(float number)
  6. decimalPlace(float theValue, int theDecimalPlaces)