Example #1
0
        /**
         * Returns the unit in the last place (ULP) of this {@code BigDecimal}
         * instance. An ULP is the distance to the nearest big decimal with the same
         * precision.
         * <p>
         * The amount of a rounding error in the evaluation of a floating-point
         * operation is often expressed in ULPs. An error of 1 ULP is often seen as
         * a tolerable error.
         * <p>
         * For class {@code BigDecimal}, the ULP of a number is simply 10^(-scale).
         * <p>
         * For example, {@code new BigDecimal(0.1).ulp()} returns {@code 1E-55}.
         *
         * @return unit in the last place (ULP) of this {@code BigDecimal} instance.
         */

        public static BigDecimal Ulp(BigDecimal value)
        {
            return(BigDecimal.Create(1, value.Scale));
        }