Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Groovy sqrt()

class Example { 
   static void main(String[] args) { 
      double x = 11.635; 
      double y = 2.76; 
	  
      System.out.printf("The value of e is %.4f%n", Math.E); 
      System.out.printf("sqrt(%.3f) is %.3f%n", x, Math.sqrt(x)); 
   } 
}

Groovy pow()

class Example {
   static void main(String[] args) {
      double x = 11.635;
      double y = 2.76; 
   
      System.out.printf("The value of e is %.4f%n", Math.E);
      System.out.printf("pow(%.3f, %.3f) is %.3f%n", x, y, Math.pow(x, y));  
   } 
}

Groovy log()

class Example { 
   static void main(String[] args) { 
      double x = 11.635; 
      double y = 2.76;
	  
      System.out.printf("The value of e is %.4f%n", Math.E); 
      System.out.printf("log(%.3f) is %.3f%n", x, Math.log(x)); 
   } 
}

Groovy exp()

class Example {
   static void main(String[] args) {
      double x = 11.635;
      double y = 2.76;  
	  
      System.out.printf("The value of e is %.4f%n", Math.E); 
      System.out.printf("exp(%.3f) is %.3f%n", x, Math.exp(x));
   } 
}

Groovy max()

class Example { 
   static void main(String[] args) { 
      System.out.println(Math.max(12.123, 12.456)); 
      System.out.println(Math.max(23.12, 23.0)); 
   } 
}

Groovy min()

class Example { 
   static void main(String[] args) { 
      System.out.println(Math.min(12.123, 12.456)); 
      System.out.println(Math.min(23.12, 23.0)); 
   } 
}

Groovy round()

class Example { 
   static void main(String[] args) { 
      double d = 100.675; 
      double e = 100.500; 
		
      float f = 100; 
      float g = 90f;  
		
      System.out.println(Math.round(d)); 
      System.out.println(Math.round(e)); 
      System.out.println(Math.round(f));
      System.out.println(Math.round(g)); 
   } 
}

Groovy - rint()

class Example { 
   static void main(String[] args){ 
      double d = 100.675; 
      double e = 100.500; 
      double f = 100.200;
		
      System.out.println(Math.rint(d)); 
      System.out.println(Math.rint(e)); 
      System.out.println(Math.rint(f)); 
   } 
}

Groovy - floor()

class Example { 
   static void main(String[] args) { 
      double a = -100.675; 
      float b = -90; 
		
      System.out.println(Math.floor(a)); 
      System.out.println(Math.floor(b)); 
   } 
}

Groovy ceil()

class Example { 
   static void main(String[] args) { 
      double a = -100.675; 
      float b = -90;
		
      System.out.println(Math.ceil(a)); 
      System.out.println(Math.ceil(b)); 
   } 
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.