KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > lang > Math

java.lang
Class Math

java.lang.Object
  extended by java.lang.Math
See Also:
Top Examples, Source Code

public static double abs(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[35]MathAbs
By pan_khandar { at } yahoo { dot } co { dot } uk on 2002/09/05 22:11:21  Rate
import java.lang.*; 
 public class MathAbs  {  
   public static void main ( String args [  ]  )   {  
     double d = -20; 
     System.out.println ( "The absolute value of d is " + Math.abs ( d )  ) ; 
    }  
  
  
  } 


public static float abs(float a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1519]What is the value of 64 >>> 32?
By Anonymous on 2005/08/20 06:40:02  Rate
//What is the value of 64  >  >  >  32? 
  
  
  
 public class Bits 
  {  
   public static void main ( String  [  ]  args )   {  
   int leftVal = 64; 
   for  ( int rightVal = 0; rightVal  <  40; rightVal++ )   {  
     System.out.println ( leftVal + "  >  >  >  " + rightVal + " = " + 
          ( leftVal  >  >  >  rightVal )  ) ; 
    }  
    }  
  }  
  
  
 Output is: 
  
  
 $ java Bits 
 64  >  >  >  0 = 64 
 64  >  >  >  1 = 32 
 64  >  >  >  2 = 16 
 64  >  >  >  3 = 8 
 64  >  >  >  4 = 4 
 64  >  >  >  5 = 2 
 64  >  >  >  6 = 1 
 64  >  >  >  7 = 0 
 ... 
 64  >  >  >  31 = 0 
 64  >  >  >  32 = 64 
 64  >  >  >  33 = 32 
 64  >  >  >  34 = 16 
 64  >  >  >  35 = 8 
 64  >  >  >  36 = 4 
 64  >  >  >  37 = 2 
 64  >  >  >  38 = 1 
 64  >  >  >  39 = 0 
 


public static int abs(int a)
See Also:
Integer.MIN_VALUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static long abs(long a)
See Also:
Long.MIN_VALUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double acos(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double asin(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double atan(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double atan2(double y,
                           double x)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double cbrt(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double ceil(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double cos(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double cosh(double x)
See Also:
Euler s number
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final double E
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double exp(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double expm1(double x)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double floor(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double hypot(double x,
                           double y)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double IEEEremainder(double f1,
                                   double f2)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double log(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double log10(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double log1p(double x)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double max(double a,
                         double b)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static float max(float a,
                        float b)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static int max(int a,
                      int b)
See Also:
Long.MAX_VALUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static long max(long a,
                       long b)
See Also:
Long.MAX_VALUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double min(double a,
                         double b)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static float min(float a,
                        float b)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static int min(int a,
                      int b)
See Also:
Long.MIN_VALUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static long min(long a,
                       long b)
See Also:
Long.MIN_VALUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final double PI
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double pow(double a,
                         double b)
See Also:
floor, ceil
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[453]c = a ^ b
By roe { at } ninje { dot } com on 2003/10/12 12:26:10  Rate
// c = a ^ b 
 c = Math.pow ( a, b ) ;


[2000]
By Anonymous on 2009/09/24 16:52:09  Rate
public static double pow ( double a, double b )   {    
      final long tmp =  ( long )   ( 9076650 *  ( a - 1 )  /  ( a + 1 + 4 *  ( Math.sqrt ( a )  )  )  * b + 1072632447 ) ;   
      return Double.longBitsToDouble ( tmp  <  <  32 ) ;   
      } 


public static double random()
See Also:
Random.nextDouble()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1501]Word list
By sivga on 2005/08/01 12:30:40  Rate
String [  ]  wordListOne =  { "24/7","sivga","java","sun","l4" } ; 
      
 int oneLength = wordListOne.length; 
      
 int rand1 =  ( int )   ( Math.random (  )  * oneLength ) ; 
 


public static double rint(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static long round(double a)
See Also:
Long.MIN_VALUE, Long.MAX_VALUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[198]Get the unrounded decimal portion
By Anonymous on 2003/10/17 17:27:10  Rate
double intPortion = Math.floor (  unroundedValue  ) ; 
  
  
 // Get the unrounded decimal portion 
 double unroundedDecimalPortion =  (  unroundedValue - intPortion  ) ; 
  
  
 /* ALERT - This next code interferes with I18N. We eventually need */ 
 /* to change this not assume only round to 2 decimal places. */ 
  
  
 /* Multiply the decimal places by 100, which shitfs the decimal point 
 /* two places to the left. Then round it so that we get a round to 
 /* two decimal places. For example, if we started with 17.655 and stripped 
 /* off the int portion, which left .655. After we shift, we are left with 
 /* 65.5. Then a round will gives us 66. We can then put it all back 
 /* together */ 
 double roundedDecimalPortion = Math.round (  unroundedDecimalPortion * 100  ) ; 
  
  
 // Shift the decimal point back two places to the right 
 roundedDecimalPortion = roundedDecimalPortion / 100; 
  
  
 // Add the int portion and decimal portions back together 
 double total = intPortion + roundedDecimalPortion; 
  
  
 return new Double (  total  ) ; 
  }  
 


[762]Round a double
By Anonymous on 2004/05/05 06:45:26  Rate
double a = 2.223; 
 int b = round ( a ) ; 
 system.out.println ( b ) ;


public static int round(float a)
See Also:
Integer.MIN_VALUE, Integer.MAX_VALUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double signum(double d)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static float signum(float f)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double sin(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double sinh(double x)
See Also:
Euler s number
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double sqrt(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double tan(double a)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double tanh(double x)
See Also:
cosh(x), sinh(x)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double toDegrees(double angrad)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double toRadians(double angdeg)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static double ulp(double d)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static float ulp(float f)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags