Using log base 10 in a formula in Java

后端 未结 5 523
遥遥无期
遥遥无期 2021-01-07 16:18

I\'m trying to write a Java program that can take values and put them into a formula involving log base 10.

How can I calculate log10 in Java?

5条回答
  •  -上瘾入骨i
    2021-01-07 16:57

    the below complete example may help you

    public class Log10Math {
        public static void main(String args[]) {
            // Method returns logarithm of number argument with base ten(10);
            short shortVal = 10;
            byte byteVal = 1;
            double doubleVal = Math.log10(byteVal);
    
            System.out.println("Log10 Results");
            System.out.println(Math.log10(1));
            System.out.println(doubleVal);
            System.out.println(Math.log10(shortVal));
        }
    }
    

    Output

    Log10 Results
    0.0
    0.0
    1.0
    

提交回复
热议问题