List of usage examples for java.lang Math pow
@HotSpotIntrinsicCandidate public static double pow(double a, double b)
From source file:Power.java
public static void main(String[] args) { System.out.println(Math.pow(2, 2)); }
From source file:Main.java
public static void main(String[] args) { // returns 2 raised to 2, i.e. 4 System.out.println(Math.pow(2, 2)); // returns -3 raised to 2, i.e. 9 System.out.println(Math.pow(-3, 2)); }
From source file:MainClass.java
public static void main(String args[]) { System.out.println(Math.pow(2, 12)); }
From source file:Main.java
public static void main(String[] args) { double x = 1.2; double y = 5.4; // print x raised by y and then y raised by x System.out.println("Math.pow(" + x + "," + y + ")=" + Math.pow(x, y)); System.out.println("Math.pow(" + y + "," + x + ")=" + Math.pow(y, x)); }
From source file:MainClass.java
public static void main(String[] args) { // Display the square root of 2 using sqrt() System.out.print("sqrt(2.0) = "); System.out.println(Math.sqrt(2.0)); // Calculate and display using pow() System.out.print("pow(2.0, 0.5) = "); System.out.println(Math.pow(2.0, 0.5)); System.out.println();//from w w w . j a v a 2 s. c o m }
From source file:Main.java
public static void main(String[] args) { List<Integer> numbers = Arrays.asList(1, 2, 3); // accepting integer, returning double System.out.println(mapIt(numbers, x -> Math.pow(10, x))); }
From source file:Main.java
public static void main(String[] args) { // Integer's sum MyCal<Integer> myOwnCalculatorFI = (a, b) -> (a + b); Integer sum = myOwnCalculatorFI.calcIt(5, 5); System.out.println("Sum: " + sum); // String's sum MyCal<String> myOwnCalculatorFI1 = (e, f) -> (e + f); System.out.println("Adder: " + myOwnCalculatorFI1.calcIt("a", "b")); // Double's power MyCal<Double> calculator2 = (a, b) -> (Math.pow(a, b)); System.out.println("Integer's range: " + calculator2.calcIt(2D, 32D)); }
From source file:MainClass.java
public static void main(String[] args) { double num, loge, log10, aloge, alog10; // Obtain input from user num = 0.111d;/*from ww w. ja va 2 s . c o m*/ // Calculate and display the natural logarithm loge = Math.log(num); System.out.println("log base e = " + loge); // Calculate the common log log10 = Math.log(num) / Math.log(10.0); System.out.println("log base 10 = " + log10); // Calculate the antilogarithm of log base e aloge = Math.exp(loge); System.out.println("antilog of log base e = " + aloge); // Calculate the antilogarithm of log base 10 alog10 = Math.pow(10.0, log10); System.out.println("anitlog of log base 10 = " + alog10); }
From source file:Main.java
public static void main(String[] argv) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int i = 0; i < gs.length; i++) { DisplayMode dm = gs[i].getDisplayMode(); int refreshRate = dm.getRefreshRate(); if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) { System.out.println("Unknown rate"); }/*from w ww . ja v a 2s .co m*/ int bitDepth = dm.getBitDepth(); int numColors = (int) Math.pow(2, bitDepth); } }
From source file:Main.java
public static void main(String[] args) { int a = 10;/*from w ww . j a va2 s . c o m*/ int b = -50; int c = 3; double x = 25.0; double y = 3.0; double z = 4.0; System.out.println("abs(b) = " + Math.abs(b)); System.out.println("cbrt(x) = " + Math.cbrt(x)); System.out.println("exp(y) = " + Math.exp(z)); System.out.println("hypot(y, z)= " + Math.hypot(y, z)); System.out.println("log(y) = " + Math.log(y)); System.out.println("log10(y) = " + Math.log10(y)); System.out.println("max(a, b) = " + Math.max(a, b)); System.out.println("min(a, b) = " + Math.min(a, b)); System.out.println("pow(a, c) = " + Math.pow(a, c)); System.out.println("random() = " + Math.random()); System.out.println("signum(b) = " + Math.signum(b)); System.out.println("sqrt(x) = " + Math.sqrt(y)); }