Math review of commonly used functions

com.ethjava Package; 

Import Classes in java.math *;. 

public class mathhanshulianxi { 
    public static void main (String [] args) { 
        int NUM = 36; 
        Double the Math.sqrt = Gen (36); 
        System.out.println ( "seek root: "+ gen); // square root: 6.0 
        int Gen2 = (int) the Math.sqrt (36); 
        System.out.println (" square root: "+ gen2); // square root:. 6 

        Double lifanggen = Math.cbrt (. 8); 
        System.out.println ( "seeking cube root:" + lifanggen); // find cube root: 2.0 
        int lifanggen2 = (int) Math.cbrt (. 8); 
        System.out.println ( "cube root seek : "+ lifanggen2); // find cube root: 2 

        Double the Math.abs jueduizhi = (-2.0);  
        System.out.println (" absolute value: "+ jueduizhi);
        int jueduizhi2 the Math.abs = (-2); 
        System.out.println ( "absolute value:" + jueduizhi2); 
        int = jueduizhi3 the Math.abs (-63); 
        System.out.println ( "absolute value:" jueduizhi3 +); 
        int = jueduizhi4 the Math.abs (63 is); 
        System.out.println ( "absolute value:" + jueduizhi4); 
        // absolute value: 2.0 
        @ absolute value: 2 
        @ absolute value: 63 
        @ absolute value: 63 

        @ th power calculating 
        Double cifang Math.pow = (2,. 3); 
        System.out.println ( "is a power of 2. 3:" + cifang); 
        // 2. 3 times side is: 8.0 
        int pingfang = (int) Math.pow (3, 2); 
        System.out.println ( "power of 2 is 3:" + pingfang); 
        // 2 power is 3: 9 

        @ whichever is greater and the smaller of two numbers 
        int = maxNum Math.max (3,. 4); 
        the System .out.println ( "the larger the number of two values:" + maxNum);
        // the value of the larger of two numbers:. 4 

        Double minNumDouble Math.min = (3.6, 6.3); 
        System.out.println ( "two numbers smaller value:" + minNumDouble); 
        // two numbers a smaller value: 3.6 

        // random number 
        System.out.println (Math.random ()); // [0, 1) the number of double type 
        //0.15667207273587436 
        //0.4421616733285778 

        // rounded 
        long numWuru = Math. round (3.5 of); 
        System.out.println (numWuru); //. 4 
        // 
        Long numSishe Math.round = (3.1); 
        System.out.println (numSishe);. 3 //
 
        //Math.ceil () - returns the number greater than or equal to the smallest integer parameters (floor function), the digital rounding up 
        double a = Math.ceil (3.11);
        System.out.println (A); // 4.0 
        Double Math.ceil = A1 (3.0); 
        System.out.println (A1); // 3.0 
        Double Math.ceil A2 = (3.9); 
        System.out.println ( A2); 4.0 // 
        /// Math.floor () - returns a numeric parameter less than or equal to the maximum integer, the rounding of numbers 
        Double Math.floor B = (3.11); 
        System.out.println (B); //3.0 
        Double Math.floor B1 = (3.99); 
        System.out.println (B1); // 3.0 
        Double Math.floor B2 = (4.0); 
        System.out.println (B2); // 4.0 

        // here recalled modulo function 
        int = qumo Math.floorMod (3,2-); 
        System.out.println (qumo); //. 1 
        int = qumo2 Math.floorMod (-3,2); 
        System.out.println ( qumo); // 1 
        // this is the first step taken modulo quotient function of the difference I can see and take notes modulo 
        int = qushang Math.floorDiv (-3,2); 
        System.out.println (qushang); // -2 
        // E of the power 
        double ecimi = Math.exp (1);
        System.out.println (ecimi); 2.718281828459045 // 
        // log 
        Double Math.log10 = log (10); // base 10 
        System.out.println (log); // 1.0 

        Double Iog2 The Math.log = ( ecimi); // base e 
        System.out.println (Iog2); // 1.0 










    } 
}

reference:

https://www.cnblogs.com/XingLifeng/p/11082779.html

https://blog.csdn.net/xuexiangjys/article/details/79849888

Published 45 original articles · won praise 8 · views 5859

Guess you like

Origin blog.csdn.net/wenyunick/article/details/103524721