Search Here

Apex Double datatype

 In Apex, the Double data type is used to represent decimal numbers with a high degree of precision. A Double is a 64-bit double-precision floating-point number, which allows it to store both integer and fractional parts of a number. It provides a high level of accuracy for working with decimal values.


public class DoubleExample {

    public static void main() {

        Double pi = 3.14159265359;

        Double taxRate = 0.0825;

        

        System.debug('Value of Pi: ' + pi);

        System.debug('Tax Rate: ' + taxRate);

        

        // Performing arithmetic operations with Double values

        Double result = pi * 2;

        System.debug('2 * Pi: ' + result);

    }

}

We declare a Double variable pi and initialize it with an approximation of the mathematical constant π (pi).


We declare a Double variable taxRate and set it to a tax rate of 8.25%.


We use System.debug() to print the values of pi and taxRate.


We perform an arithmetic operation by multiplying pi by 2 and store the result in the result variable.




Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.