Machine Precision
Exercise 1 (see code provided below)
Note: If not using the Jar, then place DhbMath in you project
Part a:
For the machine you are using, find: Largest and smallest numbers, machine precision, radix, and negative machine precision using techniques covered in Chapter 1
Part b:
Define the above terms and summarize their importance in numerical methods. In addition to the coverage in the Java text, these items are also described in the C++ text in sections 1.4 and 20.1
The following code accesses the public member functions of the DhbMath class.
Note that since the functions are declared static the code uses the fully qualified name; an object does not have to be created.
import alpcentauri.*;
class MachinePrecision
{
public static void main(String[] args)
{
System.out.println("Largest Number = : "+DhbMath.getLargestNumber());
System.out.println("Smallest Number = : "+DhbMath.getSmallestNumber());
System.out.println("Machine Precision = : "+DhbMath.getMachinePrecision());
System.out.println("Negative Machine Precision = : "+DhbMath.getNegativeMachinePrecision());
System.out.println("Radix = : " + DhbMath.getRadix());
}
}
