StrictMath.fma(double, double, double) in Java

StrictMath.fma(double, double, double): This method is available in java.lang.StrictMath class of Java.

Syntax:

double java.lang.StrictMath.fma(double a, double b, double c)

This method takes three arguments of type double as its parameters. This method returns the fused multiply-add of the three arguments; that is, returns the exact product of the first two arguments summed with the third argument and then rounded once to the nearest double.

Special cases:

1. If any argument is NaN, the result is NaN.

2. If one of the first two arguments is infinite and the other is zero, the result is NaN.

3. If the exact product of the first two arguments is infinite and the third argument is an infinity of the opposite sign, the result is NaN.

Parameters: Three parameters are required for this method.

a: a value.

b: a value.

c: a value.

Returns: (a × b + c) computed, as if with unlimited range and precision, and rounded once to the nearest double value.

Exceptions: NA

Approach

Java

public class StrictMathfmadouble {
    public static void main(String[] args) {

        double a = 1991.89, b = 110, c = 1001;
        System.out.println(StrictMath.fma(a, b, c));
    }
}

Output:

220108.90000000002


No comments:

Post a Comment