Example below demonstrates working of bigdecimal class ulp method. Method returns bigdecimal values. Method returns the size of an ulp. which is the size of a unit at the last place of the bigdecimal object value.
Method returns +1 for a positive bigdecimal value. Actually this ulp size is the difference between the bigdecimal value and just the next number after the bigdecimal value. For example, if the bigdecimal value is 4 then its next value is 5, and there difference that is one, is the value that the ulp method generates.
The scale of the result will be same as that of the this.object value.
Method represents the bigdecimal object value in scientific notations if required. For example if method generates 5E-5, then it means 5 * ten to the power minus 5.
Method generates NumberFormatException, if it finds the bigdecimal value other than integers and double types values.
Syntax for using the method: public
Suppose we have bigdecimal objects x & y;
then y = x.ulp();
Liked it! Share this Tutorial