fma(): This method is available in the Math class of Java.
Syntax:
float java.lang.Math.fma(float a, float b, float c)
This method takes three arguments of type float 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 float.
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(in other words,at least one of the arguments is infinite and the other is neither zero nor NaN) 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 float value
For Example:
Math.fma(4,5,6) = > It returns 26.0
Approach
Java
public class FmaFloat {public static void main(String[] args) {float a = 4, b = 5, c = 6;System.out.println(Math.fma(a, b, c));}}
Output:
26.0
No comments:
Post a Comment