Math log based 2 - Java java.lang

Java examples for java.lang:Math Algorithm

Description

Math log based 2

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        double num = 2.45678;
        System.out.println(log2(num));
    }/*w  w w .j  av  a2s  . c  o  m*/

    public static double log2(double num) {
        return (Math.log(num) / Math.log(2));
    }
}

Related Tutorials