Mega Code Archive

 
Categories / Java Book / 001 Language Basics
 

0016 double

double represents double-precision numbers. double is 64-bit width and its range is from 4.9e-324 to 1.8e+308 approximately. Here is a program that uses double variables to compute the area of a circle: public class Main { public static void main(String args[]) { double pi, r, a; r = 10.8888; // radius of circle pi = 3.1415926; // pi, approximately a = pi * r * r; System.out.println("Area of circle is " + a); } } The output: Area of circle is 372.4859596381597