Stage 0 Draft / May 28, 2026

Fused Multiply Add

1 FMAMultiply ( x, y )

The abstract operation FMAMultiply takes arguments x (a Number) and y (a Number) and returns either a non-zero mathematical value, not-a-number, positive-infinity, negative-infinity, positive-zero, or negative-zero. It computes the exact mathematical product of x and y.

The behaviour matches that of Number::multiply except that no rounding takes place and the result is either an exact non-zero mathematical value or an enum indicating a signed zero, a signed infinity, or NaN.

It performs the following steps when called:

  1. If x is NaN or y is NaN, return not-a-number.
  2. Let sign be 1.
  3. If x is -0๐”ฝ or x < -0๐”ฝ, then
    1. Set x to Number::unaryMinus(x).
    2. Set sign to -sign.
  4. If y is -0๐”ฝ or y < -0๐”ฝ, then
    1. Set y to Number::unaryMinus(y).
    2. Set sign to -sign.
  5. Assert: x and y both have positive signs.
  6. If x is +โˆž๐”ฝ or y is +โˆž๐”ฝ, then
    1. If x is +0๐”ฝ or y is +0๐”ฝ, return not-a-number.
    2. If sign is -1, return negative-infinity.
    3. Return positive-infinity.
  7. If x is +0๐”ฝ or y is +0๐”ฝ, then
    1. If sign is -1, return negative-zero.
    2. Return positive-zero.
  8. Assert: x and y are both non-zero and finite.
  9. Return sign ร— โ„(x) ร— โ„(y).

2 Math.fma ( x, y, z )

This function performs fused multiply-add according to the rules of IEEE 754-2019 binary double-precision arithmetic, computing (x ร— y) + z as a single operation with no intermediate rounding of the product.

It performs the following steps when called:

  1. Let nx be ?ย ToNumber(x).
  2. Let ny be ?ย ToNumber(y).
  3. Let nz be ?ย ToNumber(z).
  4. Let product be FMAMultiply(nx, ny).
  5. If product is not-a-number or nz is NaN, return NaN.
  6. If product is positive-infinity, then
    1. If nz is -โˆž๐”ฝ, return NaN.
    2. Return +โˆž๐”ฝ.
  7. If product is negative-infinity, then
    1. If nz is +โˆž๐”ฝ, return NaN.
    2. Return -โˆž๐”ฝ.
  8. If nz is either +โˆž๐”ฝ or -โˆž๐”ฝ, return nz.
  9. If product is negative-zero, return nz.
  10. If product is positive-zero, set product to 0.
  11. Assert: product and nz are both finite.
  12. Return ๐”ฝ(product + โ„(nz)).
Note

The single call to ๐”ฝ in the final step performs exactly one rounding of the infinite-precision product and sum.

Copyright & Software License

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.