Skip to content

Math.Pow does not follow IEEE 754 for all inputs #7511

@tannergooding

Description

@tannergooding

The IEEE 754 spec defines the following inputs as special:

For the pown function (integral exponents only):

  • pown (x, 0) is 1 for any x (even a zero, quiet NaN, or infinity)
  • pown (±0, n) is ±∞ and signals the divideByZero exception for odd integral n < 0
  • pown (±0, n) is +∞ and signals the divideByZero exception for even integral n < 0
  • pown (±0, n) is +0 for even integral n > 0
  • pown (±0, n) is ±0 for odd integral n > 0.

For the pow function (integral exponents get special treatment):

  • pow (x, ±0) is 1 for any x (even a zero, quiet NaN, or infinity)
  • pow (±0, y) is ±∞ and signals the divideByZero exception for y an odd integer < 0
  • pow (±0, −∞) is +∞ with no exception
  • pow (±0, +∞) is +0 with no exception
  • pow (±0, y) is +∞ and signals the divideByZero exception for finite y < 0 and not an odd integer
  • pow (±0, y) is ±0 for finite y > 0 an odd integer
  • pow (±0, y) is +0 for finite y > 0 and not an odd integer
  • pow (−1, ±∞) is 1 with no exception
  • pow (+1, y) is 1 for any y (even a quiet NaN)
  • pow (x, y) signals the invalid operation exception for finite x < 0 and finite non-integer y.

For the powr function (derived by considering only exp(y * log(x))):

  • powr (x, ±0) is 1 for finite x > 0
  • powr (±0, y) is +∞ and signals the divideByZero exception for finite y < 0
  • powr (±0, −∞) is +∞
  • powr (±0, y) is +0 for y > 0
  • powr (+1, y) is 1 for finite y
  • powr (x, y) signals the invalid operation exception for x < 0
  • powr (±0, ±0) signals the invalid operation exception
  • powr (+∞, ±0) signals the invalid operation exception
  • powr (+1, ±∞) signals the invalid operation exception
  • powr (x, qNaN) is qNaN for x ≥ 0
  • powr (qNaN, y) is qNaN.

However, the current implementation does not return the correct values for a number of these inputs (especially around the handling of NaN).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.RuntimeenhancementProduct code improvement that does NOT require public API changes/additionshelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions