Udostępnij za pośrednictwem


StrictMath.Fma Method

Definition

Overloads

Fma(Double, Double, Double)

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.

Fma(Single, Single, Single)

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.

Fma(Double, Double, Double)

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.

[Android.Runtime.Register("fma", "(DDD)D", "", ApiSince=33)]
public static double Fma (double a, double b, double c);
[<Android.Runtime.Register("fma", "(DDD)D", "", ApiSince=33)>]
static member Fma : double * double * double -> double

Parameters

a
Double

a value

b
Double

a value

c
Double

a value

Returns

(a&nbsp;&times;&nbsp;b&nbsp;+&nbsp;c) computed, as if with unlimited range and precision, and rounded once to the nearest double value

Attributes

Remarks

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.

The rounding is done using the java.math.RoundingMode#HALF_EVEN round to nearest even rounding mode.

In contrast, if a * b + c is evaluated as a regular floating-point expression, two rounding errors are involved, the first for the multiply operation, the second for the addition operation.

Special cases: <ul> <li> If any argument is NaN, the result is NaN.

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

<li> 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.

</ul>

Note that fusedMac(a, 1.0, c) returns the same result as (a + c). However, fusedMac(a, b, +0.0) does <em>not</em> always return the same result as (a * b) since fusedMac(-0.0, +0.0, +0.0) is +0.0 while (-0.0 * +0.0) is -0.0; fusedMac(a, b, -0.0) is equivalent to (a * b) however.

Added in 9.

Java documentation for java.lang.StrictMath.fma(double, double, double).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Fma(Single, Single, Single)

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.

[Android.Runtime.Register("fma", "(FFF)F", "", ApiSince=33)]
public static float Fma (float a, float b, float c);
[<Android.Runtime.Register("fma", "(FFF)F", "", ApiSince=33)>]
static member Fma : single * single * single -> single

Parameters

a
Single

a value

b
Single

a value

c
Single

a value

Returns

(a&nbsp;&times;&nbsp;b&nbsp;+&nbsp;c) computed, as if with unlimited range and precision, and rounded once to the nearest float value

Attributes

Remarks

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.

The rounding is done using the java.math.RoundingMode#HALF_EVEN round to nearest even rounding mode.

In contrast, if a * b + c is evaluated as a regular floating-point expression, two rounding errors are involved, the first for the multiply operation, the second for the addition operation.

Special cases: <ul> <li> If any argument is NaN, the result is NaN.

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

<li> 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.

</ul>

Note that fma(a, 1.0f, c) returns the same result as (a + c). However, fma(a, b, +0.0f) does <em>not</em> always return the same result as (a * b) since fma(-0.0f, +0.0f, +0.0f) is +0.0f while (-0.0f * +0.0f) is -0.0f; fma(a, b, -0.0f) is equivalent to (a * b) however.

Added in 9.

Java documentation for java.lang.StrictMath.fma(float, float, float).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to