Example usage for java.lang Math PI

List of usage examples for java.lang Math PI

Introduction

In this page you can find the example usage for java.lang Math PI.

Prototype

double PI

To view the source code for java.lang Math PI.

Click Source Link

Document

The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    System.out.printf("Decimal:               %f\n", Math.PI);
}

From source file:MainClass.java

public static void main(String[] args) {
    System.out.printf("Decimal/Scientific:    %g\n", Math.PI);
}

From source file:MainClass.java

public static void main(String[] args) {
    System.out.printf("Scientific notation:   %e\n", Math.PI);
}

From source file:MainClass.java

public static void main(String[] args) {
    System.out.printf("Decimal/Scientific:    %G\n", Math.PI);
}

From source file:MainClass.java

public static void main(String[] args) {
    System.out.printf("Uppercase Hexadecimal: %A\n", Math.PI);
}

From source file:MainClass.java

public static void main(String[] args) {
    System.out.printf("Scientific notation:   %E\n", Math.PI);
}

From source file:MainClass.java

public static void main(String[] args) {
    System.out.printf("Lowercase Hexadecimal: %a\n", Math.PI);
}

From source file:Main.java

public static void main(String[] args) {

    // get a variable x which is equal to PI/2
    double x = Math.PI / 2;

    // convert x to Radians
    x = Math.toRadians(x);/*w ww.  j  av  a2  s  .c om*/

    // get the arc sine of x
    System.out.println("Math.asin(" + x + ")=" + Math.asin(x));
}

From source file:Main.java

public static void main(String[] args) {

    // get a variable x which is equal to PI/2
    double x = Math.PI / 2;

    // convert x to radians
    x = Math.toRadians(x);/*  w ww .ja v  a2 s.  c  o m*/

    // get the arc tangent of x
    System.out.println("Math.atan(" + x + ")" + Math.atan(x));
}

From source file:PrintfExamples.java

public static void main(String[] args) {

    // num is 3.141593
    System.out.printf("num is %f\n", Math.PI);
    // num is 3.14
    System.out.printf("num is %.2f\n", Math.PI);

}